fix(server): cleanup db connections upon exit

pull/6259/head
kontrollanten 2024-03-08 22:13:51 +01:00
parent bfdd4d10f3
commit 8c30eb1b69
1 changed files with 4 additions and 1 deletions

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'
@ -372,6 +372,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 }))
})