mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
graceful shutdown redis
This commit is contained in:
parent
3e291d1019
commit
d2c17f7539
2 changed files with 9 additions and 7 deletions
|
|
@ -39,7 +39,7 @@ export class RedisDataSource {
|
|||
await this.workerRedisClient?.quit()
|
||||
await this.redisClient?.quit()
|
||||
} catch (err) {
|
||||
console.error('error while shutting down redis')
|
||||
console.error('error while shutting down redis', err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,14 +24,16 @@ redis.on('error', (err) => {
|
|||
console.error('Redis error', err)
|
||||
})
|
||||
|
||||
redis.on('close', () => {
|
||||
console.log('Redis connection closed')
|
||||
})
|
||||
|
||||
export const gracefulShutdown = async (signal: string) => {
|
||||
console.log(`Received ${signal}, closing server...`)
|
||||
await redis.quit()
|
||||
process.exit(0)
|
||||
try {
|
||||
await redis.quit()
|
||||
console.log('Redis connection closed')
|
||||
} catch (error) {
|
||||
console.error('Error while shutting down redis', error)
|
||||
} finally {
|
||||
process.exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
process.on('SIGINT', () => gracefulShutdown('SIGINT'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue