From ea75b84eefedaf03847612f3e4c02834e3b700ff Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 13 Aug 2020 12:39:51 +0100 Subject: [PATCH] [misc] let the orchestrator handle the process restart Note that there is also the `shutdownCleanly` interval which may notice that the shutdown has completed. There is some network IO required to signal all clients the server disconnect, so we cannot run process.exit immediately. --- services/real-time/app.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/real-time/app.js b/services/real-time/app.js index f2f756c21c..485937889d 100644 --- a/services/real-time/app.js +++ b/services/real-time/app.js @@ -98,7 +98,16 @@ function healthCheck(req, res) { } }) } -app.get('/health_check', healthCheck) +app.get( + '/health_check', + (req, res, next) => { + if (Settings.shutDownComplete) { + return res.sendStatus(503) + } + next() + }, + healthCheck +) app.get('/health_check/redis', healthCheck) @@ -167,6 +176,8 @@ function drainAndShutdown(signal) { client.disconnect() }) } + // Mark the node as unhealthy. + Settings.shutDownComplete = true }, Settings.gracefulReconnectTimeoutMs) }) shutdownCleanly(signal)