mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
publish restart requests
This commit is contained in:
17
src/meta.js
17
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));
|
||||
|
||||
Reference in New Issue
Block a user