update graceful shutdown

This commit is contained in:
Hongbo Wu
2024-04-09 16:49:03 +08:00
parent f2f18eb12b
commit 5f239d2dcb
5 changed files with 46 additions and 31 deletions

View File

@ -304,8 +304,19 @@ const main = async () => {
const gracefulShutdown = async (signal: string) => {
console.log(`[queue-processor]: Received ${signal}, closing server...`)
await new Promise<void>((resolve) => {
server.close((err) => {
console.log('[queue-processor]: Express server closed')
if (err) {
console.log('[queue-processor]: error stopping server', { err })
}
resolve()
})
})
await worker.close()
await redisDataSource.shutdown()
await appDataSource.destroy()
process.exit(0)
}