2019-06-06 23:54:32 +02:00
|
|
|
const { Nuxt, Builder } = require('nuxt')
|
2019-07-03 16:58:24 +02:00
|
|
|
|
2019-04-03 00:25:12 +02:00
|
|
|
// Import and Set Nuxt.js options
|
2019-06-10 00:40:37 +02:00
|
|
|
const nuxt_config = require('../nuxt.config.js')
|
2019-06-21 23:52:18 +02:00
|
|
|
const config = require('config')
|
2019-04-03 00:25:12 +02:00
|
|
|
|
2019-09-11 19:12:24 +02:00
|
|
|
async function main () {
|
2019-06-21 23:52:18 +02:00
|
|
|
nuxt_config.server = config.server
|
2019-08-09 13:21:32 +02:00
|
|
|
|
2019-04-03 00:25:12 +02:00
|
|
|
// Init Nuxt.js
|
2019-06-10 00:40:37 +02:00
|
|
|
const nuxt = new Nuxt(nuxt_config)
|
2019-04-03 00:25:12 +02:00
|
|
|
|
|
|
|
// Build only in dev mode
|
2019-06-10 00:40:37 +02:00
|
|
|
if (nuxt_config.dev) {
|
2019-04-03 00:25:12 +02:00
|
|
|
const builder = new Builder(nuxt)
|
|
|
|
await builder.build()
|
|
|
|
} else {
|
|
|
|
await nuxt.ready()
|
|
|
|
}
|
2019-08-09 01:58:11 +02:00
|
|
|
nuxt.listen()
|
2019-04-03 00:25:12 +02:00
|
|
|
|
2019-06-10 00:40:37 +02:00
|
|
|
// close connections/port/unix socket
|
2019-09-11 19:12:24 +02:00
|
|
|
function shutdown () {
|
2019-08-25 14:34:26 +02:00
|
|
|
nuxt.close(async () => {
|
|
|
|
const db = require('./api/models')
|
|
|
|
await db.sequelize.close()
|
2019-07-08 00:49:03 +02:00
|
|
|
process.exit()
|
|
|
|
})
|
2019-06-10 00:40:37 +02:00
|
|
|
}
|
|
|
|
process.on('SIGTERM', shutdown)
|
|
|
|
process.on('SIGINT', shutdown)
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|
2019-06-06 23:54:32 +02:00
|
|
|
|
2019-08-09 13:21:32 +02:00
|
|
|
main()
|