Graceful job queue shutdown

pull/837/head
Chocobozzz 2018-07-30 18:49:54 +02:00
parent 8e0fd45e14
commit 14f2b3ad11
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 13 additions and 0 deletions

View File

@ -195,4 +195,10 @@ async function startApplication () {
logger.info('Server listening on %s:%d', hostname, port)
logger.info('Web server: %s', CONFIG.WEBSERVER.URL)
})
process.on('exit', () => {
JobQueue.Instance.terminate()
})
process.on('SIGINT', () => process.exit(0))
}

View File

@ -83,6 +83,13 @@ class JobQueue {
}
}
terminate () {
for (const queueName of Object.keys(this.queues)) {
const queue = this.queues[queueName]
queue.close()
}
}
createJob (obj: CreateJobArgument) {
const queue = this.queues[obj.type]
if (queue === undefined) {