0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Adds SIGTERM handling

closes #4403
- adds SIGTERM handler to match SIGINT handler
This commit is contained in:
Harry Mills 2014-11-05 12:20:10 +00:00
parent d5f13e1510
commit edef05339e

View file

@ -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 () {