Skip to content

Commit 3b059d5

Browse files
committed
Merge pull request #4404 from Haegin/add-sigterm-handler
Adds SIGTERM handling
2 parents fad20c2 + edef053 commit 3b059d5

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

core/server/ghost-server.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@ GhostServer.prototype.logStartMessages = function () {
5151
config.url,
5252
'\nCtrl+C to shut down'.grey
5353
);
54-
55-
// ensure that Ghost exits correctly on Ctrl+C
56-
process.removeAllListeners('SIGINT').on('SIGINT', function () {
57-
console.log(
58-
'\nGhost has shut down'.red,
59-
'\nYour blog is now offline'
60-
);
61-
process.exit(0);
62-
});
6354
} else {
6455
console.log(
6556
('Ghost is running in ' + process.env.NODE_ENV + '...').green,
@@ -69,17 +60,27 @@ GhostServer.prototype.logStartMessages = function () {
6960
config.url,
7061
'\nCtrl+C to shut down'.grey
7162
);
72-
// ensure that Ghost exits correctly on Ctrl+C
73-
process.removeAllListeners('SIGINT').on('SIGINT', function () {
63+
}
64+
65+
function shutdown() {
66+
console.log('\nGhost has shut down'.red);
67+
if (process.env.NODE_ENV === 'production') {
68+
console.log(
69+
'\nYour blog is now offline'
70+
);
71+
} else {
7472
console.log(
75-
'\nGhost has shutdown'.red,
7673
'\nGhost was running for',
7774
Math.round(process.uptime()),
7875
'seconds'
7976
);
80-
process.exit(0);
81-
});
77+
}
78+
process.exit(0);
8279
}
80+
// ensure that Ghost exits correctly on Ctrl+C and SIGTERM
81+
process.
82+
removeAllListeners('SIGINT').on('SIGINT', shutdown).
83+
removeAllListeners('SIGTERM').on('SIGTERM', shutdown);
8384
};
8485

8586
GhostServer.prototype.logShutdownMessages = function () {

0 commit comments

Comments
 (0)