mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Merge pull request #19098 from overleaf/jpa-graceful-shutdown-tests
[server-ce] add test for graceful shutdown GitOrigin-RevId: 5e72e0073169009d2e3ece5a79cbd62051f6ad5b
This commit is contained in:
@@ -186,17 +186,17 @@ server.listen(port, host, function (error) {
|
||||
// Stop huge stack traces in logs from all the socket.io parsing steps.
|
||||
Error.stackTraceLimit = 10
|
||||
|
||||
function shutdownCleanly(signal) {
|
||||
function shutdownAfterAllClientsHaveDisconnected() {
|
||||
const connectedClients = io.sockets.clients().length
|
||||
if (connectedClients === 0) {
|
||||
logger.info('no clients connected, exiting')
|
||||
logger.info({}, 'no clients connected, exiting')
|
||||
process.exit()
|
||||
} else {
|
||||
logger.info(
|
||||
{ connectedClients },
|
||||
'clients still connected, not shutting down yet'
|
||||
)
|
||||
setTimeout(() => shutdownCleanly(signal), 30 * 1000)
|
||||
setTimeout(() => shutdownAfterAllClientsHaveDisconnected(), 5_000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,6 +218,7 @@ function drainAndShutdown(signal) {
|
||||
`received interrupt, starting drain over ${shutdownDrainTimeWindow} mins`
|
||||
)
|
||||
DrainManager.startDrainTimeWindow(io, shutdownDrainTimeWindow, () => {
|
||||
shutdownAfterAllClientsHaveDisconnected()
|
||||
setTimeout(() => {
|
||||
const staleClients = io.sockets.clients()
|
||||
if (staleClients.length !== 0) {
|
||||
@@ -233,7 +234,6 @@ function drainAndShutdown(signal) {
|
||||
Settings.shutDownComplete = true
|
||||
}, Settings.gracefulReconnectTimeoutMs)
|
||||
})
|
||||
shutdownCleanly(signal)
|
||||
}, statusCheckInterval)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user