graceful shutdown redis

This commit is contained in:
Hongbo Wu 2024-01-19 18:06:12 +08:00
parent 356ad38678
commit 6b89f4b809

View file

@ -73,3 +73,16 @@ export const redisDataSource = new RedisDataSource({
REDIS_URL: process.env.REDIS_URL,
REDIS_CERT: process.env.REDIS_CERT,
})
// eslint-disable-next-line @typescript-eslint/no-misused-promises
process.on('SIGINT', async () => {
console.log('SIGINT signal received.')
try {
await redisDataSource.shutdown()
} catch (error) {
console.error('error while shutting down redis', error)
}
process.exit(0)
})