2021-10-20 14:10:33 +02:00
|
|
|
export default function () {
|
|
|
|
function start (nuxt) {
|
|
|
|
const log = require('../server/log')
|
|
|
|
const config = require('../server/config')
|
|
|
|
let TaskManager
|
|
|
|
if (!config.firstrun) {
|
|
|
|
TaskManager = require('../server/taskManager').TaskManager
|
|
|
|
TaskManager.start()
|
|
|
|
}
|
2021-10-21 12:23:19 +02:00
|
|
|
log.info(`Listen on ${config.server.host}:${config.server.port}`)
|
2021-10-20 14:10:33 +02:00
|
|
|
|
|
|
|
// close connections/port/unix socket
|
|
|
|
async function shutdown () {
|
|
|
|
if (TaskManager) { TaskManager.stop() }
|
2021-10-29 15:24:20 +02:00
|
|
|
log.info('Closing DB')
|
|
|
|
const sequelize = require('../server/api/models')
|
|
|
|
await sequelize.close()
|
|
|
|
process.off('SIGTERM', shutdown)
|
|
|
|
process.off('SIGINT', shutdown)
|
|
|
|
nuxt.close()
|
|
|
|
process.exit()
|
2021-10-20 14:10:33 +02:00
|
|
|
}
|
|
|
|
process.on('SIGTERM', shutdown)
|
2021-10-29 15:24:20 +02:00
|
|
|
process.on('SIGINT', shutdown)
|
2021-10-20 14:10:33 +02:00
|
|
|
}
|
2021-10-21 12:23:19 +02:00
|
|
|
this.nuxt.hook('listen', start)
|
2021-10-20 14:10:33 +02:00
|
|
|
}
|