fix(server): cleanup db connections upon exit
This commit is contained in:
parent
4596ec2a9f
commit
29873257e7
|
@ -42,7 +42,7 @@ try {
|
||||||
// ----------- Database -----------
|
// ----------- Database -----------
|
||||||
|
|
||||||
// Initialize database and models
|
// Initialize database and models
|
||||||
import { initDatabaseModels, checkDatabaseConnectionOrDie } from './core/initializers/database.js'
|
import { initDatabaseModels, checkDatabaseConnectionOrDie, sequelizeTypescript } from './core/initializers/database.js'
|
||||||
checkDatabaseConnectionOrDie()
|
checkDatabaseConnectionOrDie()
|
||||||
|
|
||||||
import { migrate } from './core/initializers/migrator.js'
|
import { migrate } from './core/initializers/migrator.js'
|
||||||
|
@ -374,6 +374,9 @@ async function startApplication () {
|
||||||
})
|
})
|
||||||
|
|
||||||
process.on('exit', () => {
|
process.on('exit', () => {
|
||||||
|
sequelizeTypescript.close()
|
||||||
|
.catch(err => logger.error('Cannot close database connection.', { err }))
|
||||||
|
|
||||||
JobQueue.Instance.terminate()
|
JobQueue.Instance.terminate()
|
||||||
.catch(err => logger.error('Cannot terminate job queue.', { err }))
|
.catch(err => logger.error('Cannot terminate job queue.', { err }))
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue