fix restart during setup process

This commit is contained in:
lesion
2021-10-29 15:24:20 +02:00
parent df4bc563a6
commit 10d8639bf8
2 changed files with 14 additions and 10 deletions

View File

@@ -69,12 +69,15 @@ const setupController = {
})
res.json({ password, email })
// exit process so pm2 || docker could restart me || service
log.info(`Admin: ${email} / password: ${password}`)
log.info('Restart needed')
process.exit()
res.end()
// exit process so pm2 || docker could restart me || service
process.kill(process.pid)
} catch (e) {
log.error(String(e))
return res.status(400).send(String(e))
}
}

View File

@@ -12,15 +12,16 @@ export default function () {
// close connections/port/unix socket
async function shutdown () {
if (TaskManager) { TaskManager.stop() }
nuxt.close(async () => {
log.info('Closing DB')
const sequelize = require('../server/api/models')
await sequelize.close()
process.exit()
})
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()
}
process.on('SIGTERM', shutdown)
process.on('SIGINT', shutdown)
process.on('SIGINT', shutdown)
}
this.nuxt.hook('listen', start)
}