function connect(mongoDBConnectionUrl, mongoDBConnectionOption, redisUrl, cb) {
  if (arguments.length < 4) throw new Error('connect requires 4 arguments');

  async.series([
    function connectToMongoDB(callback) {
      MongoClient.connect(mongoDBConnectionUrl, mongoDBConnectionOption || {}, callback);
    },
    function connectToRedis(callback) {
      var redisOpts = {
        url: redisUrl
      };
      var client = redis.createClient(redisOpts);
      // We don't want the app to crash if Redis is not available.
      client.on('error', handleRedisError);
      return callback(null, client);
    }
  ], function(err, results) {
    if (err) {
      // If there was any problem with connecting to mongo or redis on startup,
      // the app should crash as its in an unknown state.
      throw err;
    }
    var mongoDbClient = results[0];
    var redisClient = results[1];

    server.setClients(mongoDbClient, redisClient);

    syncConnected = true;
    eventEmitter.emit('sync:ready');
    return cb(null, mongoDbClient, redisClient);
  });
}
function connect(mongoDBConnectionUrl, mongoDBConnectionOption, redisUrl, cb) {
  if (arguments.length < 4) throw new Error('connect requires 4 arguments');

  async.series([
    function connectToMongoDB(callback) {
      MongoClient.connect(mongoDBConnectionUrl, mongoDBConnectionOption || {}, callback);
    },
    function connectToRedis(callback) {
      var redisOpts = {
        url: redisUrl
      };
      var client = redis.createClient(redisOpts);
      
      client.on('error', handleRedisError);
      return callback(null, client);
    }
  ], function(err, results) {
    if (err) {
      
      
      throw err;
    }
    var mongoDbClient = results[0];
    var redisClient = results[1];

    server.setClients(mongoDbClient, redisClient);

    syncConnected = true;
    eventEmitter.emit('sync:ready');
    return cb(null, mongoDbClient, redisClient);
  });
}
function connect ( mongoDBConnectionUrl , mongoDBConnectionOption , redisUrl , cb ) { if ( arguments . length < 4 ) throw new Error ( 'connect requires 4 arguments' ) ; async . series ( [ function connectToMongoDB ( callback ) { MongoClient . connect ( mongoDBConnectionUrl , mongoDBConnectionOption || { } , callback ) ; } , function connectToRedis ( callback ) { var redisOpts = { url : redisUrl } ; var client = redis . createClient ( redisOpts ) ; // We don't want the app to crash if Redis is not available. client . on ( 'error' , handleRedisError ) ; return callback ( null , client ) ; } ] , function ( err , results ) { if ( err ) { // If there was any problem with connecting to mongo or redis on startup, // the app should crash as its in an unknown state. throw err ; } var mongoDbClient = results [ 0 ] ; var redisClient = results [ 1 ] ; server . setClients ( mongoDbClient , redisClient ) ; syncConnected = true ; eventEmitter . emit ( 'sync:ready' ) ; return cb ( null , mongoDbClient , redisClient ) ; } ) ; }
Connect to mongodb & redis with the given connection urls.
This should be called before `start()` is called

@param {string} mongoDBConnectionUrl A MongoDB connection uril in a format supported by the `mongodb` module
@param {Object} mongoDBConnectionOption mongodb connection options.
@param {string} redisUrl A redis connection url in a format supported by the `redis` module
@param {function} cb
Connect to mongodb & redis with the given connection urls . This should be called before start () is called