initialize db before nuxt is ready, fix #131

This commit is contained in:
lesion
2021-12-06 12:11:04 +01:00
parent 40f6978e76
commit 1d80faaa37
4 changed files with 16 additions and 20 deletions

View File

@@ -1,13 +1,13 @@
export default function () {
async function start (nuxt) {
export default async function () {
const log = require('../server/log')
const config = require('../server/config')
const settingsController = require('./api/controller/settings')
const dayjs = require('dayjs')
const timezone = require('dayjs/plugin/timezone')
const db = require('./api/models/index')
dayjs.extend(timezone)
await db.initialize()
await settingsController.load()
dayjs.tz.setDefault(settingsController.settings.instance_timezone)
@@ -26,11 +26,8 @@ export default function () {
await sequelize.close()
process.off('SIGTERM', shutdown)
process.off('SIGINT', shutdown)
nuxt.close()
process.exit()
}
process.on('SIGTERM', shutdown)
process.on('SIGINT', shutdown)
}
this.nuxt.hook('listen', start)
}