-
-
Notifications
You must be signed in to change notification settings - Fork 357
/
Copy pathinstall.js
35 lines (30 loc) · 959 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
// var Service = require('../lib/node-windows.js').Service;
var Service = require('node-windows').Service;
var dir = require('path').join(process.cwd(), 'helloworld.js')
// Create a new service object
var svc = new Service({
name:'Hello World',
description: 'The nodejs.org example web server.',
script: dir,
env:{
name: "NODE_ENV",
value: "production"
}
});
// Listen for the "install" event, which indicates the
// process is available as a service.
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 and let us know when the
// process has actually started working.
svc.on('start',function(){
console.log(svc.name+' started!\nVisit http://127.0.0.1:3000 to see it in action.');
});
// Install the script as a service.
console.log("Installing to", dir)
svc.install();