-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.js
executable file
·44 lines (37 loc) · 1014 Bytes
/
install.js
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
const Service = require('node-windows').Service;
/*function getDir() {
if (process.pkg) {
return path.resolve(process.execPath + "/..");
} else {
return path.join(require.main ? require.main.path : process.cwd());
}
}
*/
//using above function for a relative path.
let svc = new Service({
name: "testApp",
description: 'a test app as a service',
script: 'C:\\Users\\Dan\\Documents\\nodeExecutable\\index.js',
nodeOptions: [
'--harmony',
'--max_old_space_size=4096'
]
// env:{
// name: 'NODE_ENV',
// value: 'dev'
// }
})
//listen for install event which indicates
svc.on('install', function(){
svc.start()
})
//just in case this file is run twice.
svc.on('alreadyinstalled', function(){
console.log('this service is already installed.')
})
//listen for the start event.
svc.on('start', function(){
console.log(svc.name + 'started, visit localhost:5000')
})
//install the script as a service.
svc.install()