mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 23:45:45 +01:00
closes #6836
This commit is contained in:
13
loader.js
13
loader.js
@@ -37,7 +37,6 @@ Loader.init = function (callback) {
|
||||
}
|
||||
|
||||
process.on('SIGHUP', Loader.restart);
|
||||
process.on('SIGUSR2', Loader.reload);
|
||||
process.on('SIGTERM', Loader.stop);
|
||||
callback();
|
||||
};
|
||||
@@ -84,10 +83,6 @@ Loader.addWorkerEvents = function (worker) {
|
||||
console.log('[cluster] Restarting...');
|
||||
Loader.restart();
|
||||
break;
|
||||
case 'reload':
|
||||
console.log('[cluster] Reloading...');
|
||||
Loader.reload();
|
||||
break;
|
||||
case 'pubsub':
|
||||
workers.forEach(function (w) {
|
||||
w.send(message);
|
||||
@@ -188,14 +183,6 @@ Loader.restart = function () {
|
||||
});
|
||||
};
|
||||
|
||||
Loader.reload = function () {
|
||||
workers.forEach(function (worker) {
|
||||
worker.send({
|
||||
action: 'reload',
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Loader.stop = function () {
|
||||
killWorkers();
|
||||
|
||||
|
||||
32
src/meta.js
32
src/meta.js
@@ -39,26 +39,6 @@ Meta.userOrGroupExists = function (slug, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Reload deprecated as of v1.1.2+, remove in v2.x
|
||||
*/
|
||||
Meta.reload = function (callback) {
|
||||
restart();
|
||||
callback();
|
||||
};
|
||||
|
||||
Meta.restart = function () {
|
||||
pubsub.publish('meta:restart', { hostname: os.hostname() });
|
||||
restart();
|
||||
};
|
||||
|
||||
Meta.getSessionTTLSeconds = function () {
|
||||
var ttlDays = 60 * 60 * 24 * (parseInt(Meta.config.loginDays, 10) || 0);
|
||||
var ttlSeconds = (parseInt(Meta.config.loginSeconds, 10) || 0);
|
||||
var ttl = ttlSeconds || ttlDays || 1209600; // Default to 14 days
|
||||
return ttl;
|
||||
};
|
||||
|
||||
if (nconf.get('isPrimary') === 'true') {
|
||||
pubsub.on('meta:restart', function (data) {
|
||||
if (data.hostname !== os.hostname()) {
|
||||
@@ -67,6 +47,11 @@ if (nconf.get('isPrimary') === 'true') {
|
||||
});
|
||||
}
|
||||
|
||||
Meta.restart = function () {
|
||||
pubsub.publish('meta:restart', { hostname: os.hostname() });
|
||||
restart();
|
||||
};
|
||||
|
||||
function restart() {
|
||||
if (process.send) {
|
||||
process.send({
|
||||
@@ -76,3 +61,10 @@ function restart() {
|
||||
winston.error('[meta.restart] Could not restart, are you sure NodeBB was started with `./nodebb start`?');
|
||||
}
|
||||
}
|
||||
|
||||
Meta.getSessionTTLSeconds = function () {
|
||||
var ttlDays = 60 * 60 * 24 * (parseInt(Meta.config.loginDays, 10) || 0);
|
||||
var ttlSeconds = (parseInt(Meta.config.loginSeconds, 10) || 0);
|
||||
var ttl = ttlSeconds || ttlDays || 1209600; // Default to 14 days
|
||||
return ttl;
|
||||
};
|
||||
|
||||
13
src/start.js
13
src/start.js
@@ -118,19 +118,6 @@ function addProcessHandlers() {
|
||||
process.on('SIGTERM', shutdown);
|
||||
process.on('SIGINT', shutdown);
|
||||
process.on('SIGHUP', restart);
|
||||
process.on('message', function (message) {
|
||||
if (typeof message !== 'object') {
|
||||
return;
|
||||
}
|
||||
var meta = require('./meta');
|
||||
|
||||
switch (message.action) {
|
||||
case 'reload':
|
||||
meta.reload();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
winston.error(err);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user