From cc487a7fc86a0095a7f00063e7aec3b0c9fe221f Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 29 Dec 2014 15:31:15 -0500 Subject: [PATCH] publish restart requests --- src/meta.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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));