UNPKG

801 BJavaScriptView Raw
1var Service = require('node-linux').Service;
2
3// Create a new service object
4var svc = new Service({
5 name:'Library Manager',
6 script: require('path').join(__dirname,'libraryManager.js'),
7 user: "ubuntu",
8 group: "ubuntu",
9 // wait for restart
10 wait: 1,
11 // if restart gives error then decrease waiting time %50
12 grow: .5
13});
14
15// Listen for the "uninstall" event so we know when it's done.
16svc.on('uninstall',function(){
17 console.log('Uninstall complete.');
18 console.log('The service exists: ',svc.exists());
19});
20
21svc.on('install',function(){
22 console.log('installtion complete.');
23 console.log('The service exists: ',svc.exists());
24});
25
26svc.on('start',function(){
27 console.log('start.');
28});
29
30svc.on('error',function(){
31 svc.restart();
32});
33
34svc.uninstall();