Forcefully exit on second term signal

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2021-08-14 23:59:37 +02:00
parent b8c3703c2f
commit b8bb40b9b6
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

6
app.js
View file

@ -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) {