fix(shutdown): kill server after timeout when hanging on shutdown
When socket.io is not able to close a connection somehow, the code never reaches the final shutdown state but keeps waiting for all connections to be closed. This can cause a high CPU load on failing shutdown. It is very unlikely to happen, except when the server is shut down exactly at the same time a socket is disconnecting and not already marked as disconnected. This change adds a fallback timer which forcefully kills the server after a certain amount of time. Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
7
app.js
7
app.js
@@ -394,6 +394,13 @@ function handleTermSignals () {
|
||||
process.exit(0)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
logger.warn(`Real time server not ready for shutdown, trying again (${currentCleanTry}/${maxCleanTries})...`)
|
||||
currentCleanTry++
|
||||
if (currentCleanTry > maxCleanTries) {
|
||||
logger.error('Could not save note revisions after shutdown! Exiting.')
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
}, 200)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user