diff --git a/core/bbs.js b/core/bbs.js index 1020ee3e..58186af5 100644 --- a/core/bbs.js +++ b/core/bbs.js @@ -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); } ], () => { diff --git a/core/msg_network.js b/core/msg_network.js index 030c544e..9e0813f4 100644 --- a/core/msg_network.js +++ b/core/msg_network.js @@ -5,9 +5,9 @@ let loadModulesForCategory = require('./module_util.js').loadModulesForCategory; // standard/deps -let async = require('async'); +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(); - }); - - msgNetworkModules = []; +function shutdown(cb) { + async.each( + msgNetworkModules, + (msgNetModule, next) => { + msgNetModule.shutdown( () => { + return next(); + }); + }, + () => { + msgNetworkModules = []; + return cb(null); + } + ); } function recordMessage(message, cb) {