service-core/service/service.mjs

25 lines
624 B
JavaScript
Raw Normal View History

2020-09-01 17:31:38 +00:00
import path from 'path'
import { readFileSync } from 'fs'
import { fileURLToPath } from 'url'
import nodewindows from 'node-windows'
const __dirname = path.dirname(fileURLToPath(import.meta.url));
let config = JSON.parse(readFileSync(path.join(__dirname,'../config.json')))
const Service = nodewindows.Service
// Create a new service object
var svc = new Service({
name: config.serviceName,
description: config.description,
script: path.join(__dirname,'../runner.mjs'),
env: {
name: 'NODE_ENV',
value: 'production',
},
//, workingDirectory: '...'
//, allowServiceLogon: true
});
export default svc