From e4eb663d51e09fbeaf854cdcc5e1eb24def4375b Mon Sep 17 00:00:00 2001 From: Don Bowman Date: Tue, 1 Sep 2020 12:04:58 -0400 Subject: [PATCH 1/2] fix: add SIGTERM handle for kubernetes graceful --- server.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server.js b/server.js index a5a7c0e..500fcbb 100644 --- a/server.js +++ b/server.js @@ -76,6 +76,14 @@ function start(config) { } }).listen(config.port, config.host); + process.on('SIGTERM', () => { + log.info('SIGTERM signal received.'); + log.log('Closing http server.'); + server.close(() => { + log.log('Http server closed.'); + }); + }); + log.info('npm_lazy at', config.host, 'port', config.port); log.info('npm_lazy cache directory:', path.normalize(config.cacheDirectory)); From f209a41c160298accbb4006a5ec50a2638c11118 Mon Sep 17 00:00:00 2001 From: Don Bowman Date: Tue, 1 Sep 2020 12:08:28 -0400 Subject: [PATCH 2/2] fix: add SIGINT to graceful --- server.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server.js b/server.js index 500fcbb..2845923 100644 --- a/server.js +++ b/server.js @@ -83,6 +83,13 @@ function start(config) { log.log('Http server closed.'); }); }); + process.on('SIGINT', () => { + log.info('SIGINT signal received.'); + log.log('Closing http server.'); + server.close(() => { + log.log('Http server closed.'); + }); + }); log.info('npm_lazy at', config.host, 'port', config.port); log.info('npm_lazy cache directory:', path.normalize(config.cacheDirectory));