gancio-upstream/server/index.js

35 lines
726 B
JavaScript
Raw Normal View History

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
const nuxt_config = require('../nuxt.config.js')
const config = require('config')
2019-04-03 00:25:12 +02:00
2019-08-09 13:21:32 +02:00
async function main() {
nuxt_config.server = config.server
2019-08-09 13:21:32 +02:00
2019-04-03 00:25:12 +02:00
// Init Nuxt.js
const nuxt = new Nuxt(nuxt_config)
2019-04-03 00:25:12 +02:00
// Build only in dev mode
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
// close connections/port/unix socket
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()
})
}
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()