Skip to content

Commit 9aeba7d

Browse files
committed
Gracefully close server connections on SIGTERM.
1 parent 1220204 commit 9aeba7d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

bin/web.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,12 @@ app.use(function(err, req, res, next) {
112112
var server = app.listen(PORT, HOST, function () {
113113
console.log('Listening at http://%s:%s%s', HOST, PORT, BASE_URL);
114114
});
115+
116+
process.on('SIGTERM', function() {
117+
// runit sends a SIGTERM, then waits 10 seconds and, if necessary,
118+
// sends a SIGKILL. This lets us shut down gracefully.
119+
server.close(function() {
120+
console.log('Closed all server connections.');
121+
process.exit(0);
122+
});
123+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuts-serve",
3-
"version": "2.7.3",
3+
"version": "2.7.4",
44
"description": "Server to make GitHub releases (private) available to download with Squirrel support",
55
"main": "./lib/index.js",
66
"homepage": "https://github.com/GitbookIO/nuts",

0 commit comments

Comments
 (0)