From 7aa785b2056ab53e5352a619d5b2a6b8abee564a Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Thu, 17 Apr 2014 22:35:49 -0400 Subject: [PATCH] fixed problem with nodebb always restarting when SIGTERM'd -- @frissdiegurke --- app.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 9661002f91..f827254c24 100644 --- a/app.js +++ b/app.js @@ -143,9 +143,12 @@ function start() { process.on('SIGTERM', shutdown); process.on('SIGINT', shutdown); process.on('SIGHUP', restart); - process.on('uncaughtException', function() { + process.on('uncaughtException', function(err) { + winston.error(err.message); + console.log(err.stack); + meta.js.killMinifier(); - shutdown(); + shutdown(1); }) } else { winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:'); @@ -286,7 +289,7 @@ function shutdown(code) { winston.info('[app] Database connection closed.'); winston.info('[app] Shutdown complete.'); - process.exit(1); + process.exit(code || 0); } function restart() { @@ -297,7 +300,7 @@ function restart() { }); } else { winston.error('[app] Could not restart server. Shutting down.'); - shutdown(); + shutdown(1); } }