mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 09:02:01 +01:00
39 lines
965 B
JavaScript
39 lines
965 B
JavaScript
const { Nuxt, Builder } = require('nuxt')
|
|
|
|
// Import and Set Nuxt.js options
|
|
const nuxtConfig = require('../nuxt.config.js')
|
|
const config = require('config')
|
|
const consola = require('consola')
|
|
const { TaskManager } = require('./taskManager')
|
|
|
|
async function main () {
|
|
nuxtConfig.server = config.server
|
|
|
|
// Init Nuxt.js
|
|
const nuxt = new Nuxt(nuxtConfig)
|
|
|
|
// Build only in dev mode
|
|
if (nuxtConfig.dev) {
|
|
const builder = new Builder(nuxt)
|
|
await builder.build()
|
|
} else {
|
|
await nuxt.ready()
|
|
}
|
|
nuxt.listen()
|
|
consola.info('Listen on %s:%d , visit me here => %s', config.server.host, config.server.port, config.baseurl)
|
|
TaskManager.start()
|
|
|
|
// close connections/port/unix socket
|
|
function shutdown () {
|
|
TaskManager.stop()
|
|
nuxt.close(async () => {
|
|
const db = require('./api/models')
|
|
await db.sequelize.close()
|
|
process.exit()
|
|
})
|
|
}
|
|
process.on('SIGTERM', shutdown)
|
|
process.on('SIGINT', shutdown)
|
|
}
|
|
|
|
main()
|