Forked from whoeverest/async-connection.coffee
Last active
December 15, 2015 20:29
-
-
Save spion/5318486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg = require 'fluent-ffmpeg' | |
mongoose = require 'mongoose' | |
amqp = require 'amqp' | |
async = require 'async' | |
# Connect to RabbitMQ | |
amqpConnect = (done) -> | |
amqpConnection = amqp.createConnection {host: 'localhost'} | |
amqpConnection.on 'ready', done.bind(this, null, amqpConnection); | |
amqpConnection.on 'error', done.bind(this, "Failed connecting to rabbit"); | |
# Connect to Mongo | |
mongoConnect = (done) -> | |
mongoose.connection.on 'open', done.bind(this, null, mongoose); | |
mongoose.connection.on 'error', done.bind(this, "Failed connecting to mongo"); | |
# Wait for connections, if completed successfully, continue | |
async.parallel {amqp: amqpConnect, mongo: mongoConnect}, (err, res) -> | |
amqpConn = res.amqp; | |
mongooseDone = res.mongo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wait for connections, if completed successfully, continue | |
async.parallel { | |
amqp: amqp.createConnection.bind(amqp, {host: 'localhost'}), | |
mongo: mongoose.openConnection.bind(mongoose) | |
}, (err, res) -> | |
amqpConn = res.amqp; | |
mongooseDone = res.mongo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment