-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-service.js
More file actions
34 lines (30 loc) · 885 Bytes
/
install-service.js
File metadata and controls
34 lines (30 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const Service = require('node-windows').Service;
const path = require('path');
// Create a new service object
const svc = new Service({
name: 'Bahari Receipt Printing',
description: 'Prints receipts from the Bahari application.',
script: path.join(__dirname, 'index.js'),
nodeOptions: [
'--harmony',
'--max_old_space_size=4096'
]
});
// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install', function() {
svc.start();
console.log('Install complete.');
console.log('The service exists: ', svc.exists);
});
// Listen for the "uninstall" event so we know when it's done.
svc.on('uninstall', function() {
console.log('Uninstall complete.');
console.log('The service exists: ', svc.exists);
});
// Install the service.
if (process.argv[2] === 'uninstall') {
svc.uninstall();
} else {
svc.install();
}