Handle SIGINT in server better by moving DB call to after redis shutdown

This commit is contained in:
Jackson Harper
2024-01-18 12:00:13 +08:00
parent bb55137bb4
commit ee142d3d7c
2 changed files with 6 additions and 4 deletions

View File

@ -190,12 +190,14 @@ const main = async (): Promise<void> => {
listener.timeout = 640 * 1000 // match headersTimeout
process.on('SIGINT', async () => {
await appDataSource.destroy()
console.log('DB connection closed.')
// Shutdown redis before DB because the quit sequence can
// cause appDataSource to get reloaded in the callback
await redisDataSource.shutdown()
console.log('Redis connection closed.')
await appDataSource.destroy()
console.log('DB connection closed.')
process.exit(0)
})
}