1
0
Fork 0

fix(server): cleanup db connections upon exit

This commit is contained in:
kontrollanten 2024-03-08 22:13:51 +01:00 committed by Chocobozzz
parent 4596ec2a9f
commit 29873257e7

View file

@ -42,7 +42,7 @@ try {
// ----------- Database -----------
// Initialize database and models
import { initDatabaseModels, checkDatabaseConnectionOrDie } from './core/initializers/database.js'
import { initDatabaseModels, checkDatabaseConnectionOrDie, sequelizeTypescript } from './core/initializers/database.js'
checkDatabaseConnectionOrDie()
import { migrate } from './core/initializers/migrator.js'
@ -374,6 +374,9 @@ async function startApplication () {
})
process.on('exit', () => {
sequelizeTypescript.close()
.catch(err => logger.error('Cannot close database connection.', { err }))
JobQueue.Instance.terminate()
.catch(err => logger.error('Cannot terminate job queue.', { err }))
})