Call shutdown() of msg network modules @ shutdown

This commit is contained in:
Bryan Ashby 2016-06-20 21:05:47 -06:00
parent b17bd15c46
commit 97c2e7adc0
2 changed files with 21 additions and 9 deletions

View File

@ -100,10 +100,15 @@ function shutdownSystem() {
}, },
function stopEventScheduler(callback) { function stopEventScheduler(callback) {
if(initServices.eventScheduler) { if(initServices.eventScheduler) {
return initServices.eventScheduler.shutdown(callback); return initServices.eventScheduler.shutdown( () => {
callback(null); // ignore err
});
} else { } else {
return callback(null); return callback(null);
} }
},
function stopMsgNetwork(callback) {
require('./msg_network.js').shutdown(callback);
} }
], ],
() => { () => {

View File

@ -5,9 +5,9 @@
let loadModulesForCategory = require('./module_util.js').loadModulesForCategory; let loadModulesForCategory = require('./module_util.js').loadModulesForCategory;
// standard/deps // standard/deps
let async = require('async'); let async = require('async');
exports.startup = startup exports.startup = startup;
exports.shutdown = shutdown; exports.shutdown = shutdown;
exports.recordMessage = recordMessage; exports.recordMessage = recordMessage;
@ -36,12 +36,19 @@ function startup(cb) {
); );
} }
function shutdown() { function shutdown(cb) {
msgNetworkModules.forEach(mod => { async.each(
mod.shutdown(); msgNetworkModules,
}); (msgNetModule, next) => {
msgNetModule.shutdown( () => {
msgNetworkModules = []; return next();
});
},
() => {
msgNetworkModules = [];
return cb(null);
}
);
} }
function recordMessage(message, cb) { function recordMessage(message, cb) {