Node.js based forum software built for the modern web
an attempt at addressing loader madness... #1364
Julian Lam0a35195fc75c
diff --git a/app.js b/app.jsindex 6a1bb9d49d..51b752ccc9 100644--- a/app.js+++ b/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();diff --git a/loader.js b/loader.jsindex 2ab9be2715..e0bfac6258 100644--- a/loader.js+++ b/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();}});},diff --git a/nodebb b/nodebbindex 18f6df8966..bf7b82e42e 100755--- a/nodebb+++ b/nodebb@@ -22,7 +22,13 @@ case "$1" inecho "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 daemonnode loader -d "$@";;@@ -42,13 +48,11 @@ case "$1" inthenecho "NodeBB is not running";echo " \"./nodebb start\" to launch the NodeBB server";- return 1;elseecho "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;;diff --git a/src/meta.js b/src/meta.jsindex eef8acee95..4f2a25f7e9 100644--- a/src/meta.js+++ b/src/meta.js@@ -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`?');}