From b8bb40b9b621cca54274e5b3f3eb22c98eb6c6de Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sat, 14 Aug 2021 23:59:37 +0200 Subject: [PATCH] Forcefully exit on second term signal Signed-off-by: David Mehren --- app.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app.js b/app.js index 21efd6798..45e70c8b5 100644 --- a/app.js +++ b/app.js @@ -309,9 +309,15 @@ process.on('uncaughtException', function (err) { process.exit(1) }) +let alreadyHandlingTermSignals = false // install exit handler function handleTermSignals () { + if (alreadyHandlingTermSignals) { + logger.info('Forcefully exiting.') + process.exit(1) + } logger.info('HedgeDoc has been killed by signal, try to exit gracefully...') + alreadyHandlingTermSignals = true realtime.maintenance = true // disconnect all socket.io clients Object.keys(io.sockets.sockets).forEach(function (key) {