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 }) res.json({ password, email })
// exit process so pm2 || docker could restart me || service
log.info(`Admin: ${email} / password: ${password}`) log.info(`Admin: ${email} / password: ${password}`)
log.info('Restart needed') log.info('Restart needed')
process.exit()
res.end()
// exit process so pm2 || docker could restart me || service
process.kill(process.pid)
} catch (e) { } catch (e) {
log.error(String(e))
return res.status(400).send(String(e)) return res.status(400).send(String(e))
} }
} }

View File

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