INNER CODE UNIT · TypeScript
shutdown
aelassas/movinin · backend/src/index.ts:59
const shutdown = async (signal: string): Promise<void> => {
logger.info(`Received ${signal}. Gracefully stopping server...`)
// Force shutdown if close hangs after timeout
const shutdownTimeout = setTimeout(() => {
logger.warn('Forced shutdown due to timeout')
process.exit(1)
}, shutdownTimeoutMs)
server.close(async () => {
clearTimeout(shutdownTimeout)
logger.info(`${protocol} server closed`)
await databaseHelper.close(true)
process.exit(0)
})
}
['SIGINT', 'SIGTERM', 'SIGQUIT'].forEach((signal) => process.once(signal, shutdown))