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) {
if(initServices.eventScheduler) {
return initServices.eventScheduler.shutdown(callback);
return initServices.eventScheduler.shutdown( () => {
callback(null); // ignore err
});
} else {
return callback(null);
}
},
function stopMsgNetwork(callback) {
require('./msg_network.js').shutdown(callback);
}
],
() => {

View File

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