From edef05339eea3165bd05072cbbe7806b44a57c19 Mon Sep 17 00:00:00 2001 From: Harry Mills Date: Wed, 5 Nov 2014 12:20:10 +0000 Subject: [PATCH] Adds SIGTERM handling closes #4403 - adds SIGTERM handler to match SIGINT handler --- core/server/ghost-server.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/core/server/ghost-server.js b/core/server/ghost-server.js index bb8b7ba34e..2294720c57 100644 --- a/core/server/ghost-server.js +++ b/core/server/ghost-server.js @@ -51,15 +51,6 @@ GhostServer.prototype.logStartMessages = function () { config.url, '\nCtrl+C to shut down'.grey ); - - // ensure that Ghost exits correctly on Ctrl+C - process.removeAllListeners('SIGINT').on('SIGINT', function () { - console.log( - '\nGhost has shut down'.red, - '\nYour blog is now offline' - ); - process.exit(0); - }); } else { console.log( ('Ghost is running in ' + process.env.NODE_ENV + '...').green, @@ -69,17 +60,27 @@ GhostServer.prototype.logStartMessages = function () { config.url, '\nCtrl+C to shut down'.grey ); - // ensure that Ghost exits correctly on Ctrl+C - process.removeAllListeners('SIGINT').on('SIGINT', function () { + } + + function shutdown() { + console.log('\nGhost has shut down'.red); + if (process.env.NODE_ENV === 'production') { + console.log( + '\nYour blog is now offline' + ); + } else { console.log( - '\nGhost has shutdown'.red, '\nGhost was running for', Math.round(process.uptime()), 'seconds' ); - process.exit(0); - }); + } + process.exit(0); } + // ensure that Ghost exits correctly on Ctrl+C and SIGTERM + process. + removeAllListeners('SIGINT').on('SIGINT', shutdown). + removeAllListeners('SIGTERM').on('SIGTERM', shutdown); }; GhostServer.prototype.logShutdownMessages = function () {