This repository has been archived on 2022-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
IcyNet.eu/server/worker.js

29 lines
648 B
JavaScript

'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')
})