mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-04-14 16:38:08 +02:00
an attempt at addressing loader madness... #1364
This commit is contained in:
9
app.js
9
app.js
@@ -142,11 +142,6 @@ function start() {
|
||||
process.on('SIGTERM', shutdown);
|
||||
process.on('SIGINT', shutdown);
|
||||
process.on('SIGHUP', restart);
|
||||
process.on('uncaughtException', function(err) {
|
||||
winston.error('[app] Encountered Uncaught Exception: ' + err.message);
|
||||
console.log(err.stack);
|
||||
restart();
|
||||
});
|
||||
} else {
|
||||
winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
|
||||
winston.warn(' node app --upgrade');
|
||||
@@ -292,7 +287,9 @@ function shutdown(code) {
|
||||
function restart() {
|
||||
if (process.send) {
|
||||
winston.info('[app] Restarting...');
|
||||
process.send('nodebb:restart');
|
||||
process.send({
|
||||
action: 'restart'
|
||||
});
|
||||
} else {
|
||||
winston.error('[app] Could not restart server. Shutting down.');
|
||||
shutdown();
|
||||
|
||||
16
loader.js
16
loader.js
@@ -12,9 +12,19 @@ var nconf = require('nconf'),
|
||||
}
|
||||
});
|
||||
|
||||
nbb.on('message', function(cmd) {
|
||||
if (cmd === 'nodebb:restart') {
|
||||
nbb_restart();
|
||||
nbb.on('message', function(message) {
|
||||
if (message && typeof message === 'object' && message.action) {
|
||||
if (message.action === 'restart') {
|
||||
nbb_restart();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
nbb.on('exit', function(code, signal) {
|
||||
if (code) {
|
||||
nbb_start();
|
||||
} else {
|
||||
nbb_stop();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
10
nodebb
10
nodebb
@@ -22,7 +22,13 @@ case "$1" in
|
||||
echo "Starting NodeBB";
|
||||
echo " \"./nodebb stop\" to stop the NodeBB server";
|
||||
echo " \"./nodebb log\" to view server output";
|
||||
echo "" > ./logs/output.log;
|
||||
|
||||
if [ -f "./logs/output.log" ]; # Preserve the last output log
|
||||
then
|
||||
mv ./logs/output.log ./logs/output.1.log;
|
||||
fi;
|
||||
|
||||
# Start the loader daemon
|
||||
node loader -d "$@"
|
||||
;;
|
||||
|
||||
@@ -42,13 +48,11 @@ case "$1" in
|
||||
then
|
||||
echo "NodeBB is not running";
|
||||
echo " \"./nodebb start\" to launch the NodeBB server";
|
||||
return 1;
|
||||
else
|
||||
echo "NodeBB Running (pid $(cat pidfile))";
|
||||
echo " \"./nodebb stop\" to stop the NodeBB server";
|
||||
echo " \"./nodebb log\" to view server output";
|
||||
echo " \"./nodebb restart\" to restart NodeBB";
|
||||
return 0;
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
@@ -448,7 +448,9 @@ var fs = require('fs'),
|
||||
/* Assorted */
|
||||
Meta.restart = function() {
|
||||
if (process.send) {
|
||||
process.send('nodebb:restart');
|
||||
process.send({
|
||||
action: 'restart'
|
||||
});
|
||||
} else {
|
||||
winston.error('[meta.restart] Could not restart, are you sure NodeBB was started with `./nodebb start`?');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user