diff --git a/src/meta.js b/src/meta.js index fdaa2d8107..f5f33a60b2 100644 --- a/src/meta.js +++ b/src/meta.js @@ -3,11 +3,13 @@ var async = require('async'), winston = require('winston'), templates = require('templates.js'), + os = require('os'), user = require('./user'), groups = require('./groups'), plugins = require('./plugins'), emitter = require('./emitter'), + pubsub = require('./pubsub'), auth = require('./routes/authentication'); (function (Meta) { @@ -62,6 +64,19 @@ var async = require('async'), }; Meta.restart = function() { + pubsub.publish('meta:restart', {hostname: os.hostname()}); + restart(); + }; + + if (nconf.get('isPrimary') === 'true') { + pubsub.on('meta:restart', function(data) { + if (data.hostname !== os.hostname()) { + restart(); + } + }); + } + + function restart() { if (process.send) { process.send({ action: 'restart' @@ -69,5 +84,5 @@ var async = require('async'), } else { winston.error('[meta.restart] Could not restart, are you sure NodeBB was started with `./nodebb start`?'); } - }; + } }(exports));