Skip to content

Commit 757674c

Browse files
committed
Close http and https servers properly.
Issue mendhak#4
1 parent 879a799 commit 757674c

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ const sslOpts = {
5959
cert: require('fs').readFileSync('fullchain.pem'),
6060
};
6161

62-
http.createServer(app).listen(80);
63-
https.createServer(sslOpts,app).listen(443);
62+
var httpServer = http.createServer(app).listen(80);
63+
var httpsServer = https.createServer(sslOpts,app).listen(443);
6464

6565
let calledClose = false;
6666

@@ -75,8 +75,11 @@ process.on('exit', function () {
7575
process.on('SIGINT', function() {
7676
console.log('Got SIGINT. Trying to exit gracefully.');
7777
calledClose = true;
78-
server.close(function() {
79-
console.log("Exoress server closed. Asking process to exit.");
80-
process.exit()
78+
httpServer.close(function() {
79+
httpsServer.close(function() {
80+
console.log("HTTP and HTTPS servers closed. Asking process to exit.");
81+
process.exit()
82+
});
83+
8184
});
8285
});

0 commit comments

Comments
 (0)