mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Handle SIGINT in server better by moving DB call to after redis shutdown
This commit is contained in:
parent
bb55137bb4
commit
ee142d3d7c
2 changed files with 6 additions and 4 deletions
|
|
@ -36,7 +36,7 @@ export class RedisDataSource {
|
|||
async shutdown(): Promise<void> {
|
||||
this.isInitialized = false
|
||||
try {
|
||||
await this.workerRedisClient?.disconnect()
|
||||
await this.workerRedisClient?.quit()
|
||||
await this.redisClient?.quit()
|
||||
} catch (err) {
|
||||
console.error('error while shutting down redis')
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue