-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
61 lines (50 loc) · 1.17 KB
/
Copy pathindex.js
File metadata and controls
61 lines (50 loc) · 1.17 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var Service = require('node-windows').Service
const stdio = require('stdio')
const defaults = {
serviceName: 'WatsonServiceNode',
install: false,
uninstall: false
}
let flags = stdio.getopt({
'serviceName': {
key: 's',
description: 'The name for the service',
default: defaults.serviceName
},
'install': {
key: 'i',
description: 'Install the service',
default: defaults.install
},
'uninstall': {
key: 'u',
description: 'Uninstall the service',
default: defaults.uninstall
}
})
// Create a new service object
var svc = new Service({
name: flags.serviceName,
description: 'The service that communicates with the watson API.',
script: __dirname + '\\dist\\main.js',
abortOnError: true,
maxRetries: 0.1,
env: [{
name: "APPDATA",
value: process.env["APPDATA"]
}]
});
if (flags.install) {
svc.on('install',function () {
console.log('Installed service, starting!')
svc.start();
});
svc.install();
} else if (flags.uninstall) {
svc.on('uninstall',function () {
console.log('Uninstalled service!')
});
svc.uninstall();
} else {
console.log('Invalid usage! Use option --help for more info')
}