From 8aa75b7af4fa7a6eb98969f123275606a22b7f9c Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 29 Dec 2014 15:41:55 -0500 Subject: [PATCH] publish reload requests, fix missing nconf --- src/meta.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/meta.js b/src/meta.js index f5f33a60b2..30a9e96e75 100644 --- a/src/meta.js +++ b/src/meta.js @@ -4,6 +4,7 @@ var async = require('async'), winston = require('winston'), templates = require('templates.js'), os = require('os'), + nconf = require('nconf'), user = require('./user'), groups = require('./groups'), @@ -36,6 +37,18 @@ var async = require('async'), }; Meta.reload = function(callback) { + pubsub.publish('meta:reload', {hostname: os.hostname()}); + reload(callback); + }; + + pubsub.on('meta:reload', function(data) { + if (data.hostname !== os.hostname()) { + reload(); + } + }); + + function reload(callback) { + callback = callback || function() {}; async.series([ async.apply(plugins.clearRequireCache), async.apply(plugins.reload), @@ -57,11 +70,9 @@ var async = require('async'), emitter.emit('nodebb:ready'); } - if (callback) { - callback.apply(null, arguments); - } + callback(err); }); - }; + } Meta.restart = function() { pubsub.publish('meta:restart', {hostname: os.hostname()});