'use strict'
const path = require('path')
require('@babel/register')({
plugins: ['@babel/plugin-transform-modules-commonjs']
})
process.once('message', (args) => {
process.env.NODE_ENV = args.dev ? 'development' : 'production'
try {
require(path.join(__dirname, 'server'))(args)
console.log('Worker process starting')
} catch (e) {
console.error(e)
}
process.on('message', (message) => {
if (message !== 'stop') return
console.log('Recieved stop signal')
const knex = require(path.join(__dirname, '../scripts/load-database')).knex
knex.destroy(() => process.exit(0))
process.send('started')