initialize / shutdown dbs simultaneously

v1.18.x
psychobunny 11 years ago
parent bba3df6802
commit f3fe79ab60

@ -5,6 +5,7 @@ var nconf = require('nconf'),
secondaryDBConfig = nconf.get('secondary_database'), secondaryDBConfig = nconf.get('secondary_database'),
secondaryModules = nconf.get('secondary_db_modules'), secondaryModules = nconf.get('secondary_db_modules'),
winston = require('winston'), winston = require('winston'),
async = require('async'),
ALLOWED_MODULES = ['hash', 'list', 'sets', 'sorted']; ALLOWED_MODULES = ['hash', 'list', 'sets', 'sorted'];
@ -23,6 +24,17 @@ function setupSecondaryDB() {
primaryDB[module] = secondaryDB[module]; primaryDB[module] = secondaryDB[module];
} }
} }
var primaryDBinit = primaryDB.init,
primaryDBclose = primaryDB.close;
primaryDB.init = function(callback) {
async.parallel([primaryDBinit, secondaryDB.init], callback);
};
primaryDB.close = function(callback) {
async.parallel([primaryDBclose, secondaryDB.close], callback);
};
} }

Loading…
Cancel
Save