Skip to content

Commit fedde1f

Browse files
authored
Merge pull request #342 from countnazgul/master
Dependent on another service
2 parents 1dfb6da + b2c1b49 commit fedde1f

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,19 @@ svc.sudo.password = 'password';
239239
...
240240
```
241241

242+
### Depending on other services
243+
244+
The service can also be made dependant on other Windows services.
245+
246+
```js
247+
var svc = new Service({
248+
name:'Hello World',
249+
description: 'The nodejs.org example web server.',
250+
script: 'C:\\path\\to\\helloworld.js',
251+
dependsOn: ["serviceA"]
252+
});
253+
```
254+
242255
### Cleaning Up: Uninstall a Service
243256

244257
Uninstalling a previously created service is syntactically similar to installation.

lib/daemon.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ var daemon = function (config) {
131131
stoptimeout: this.stoptimeout,
132132
logmode: this.logmode,
133133
logging: config.logging,
134-
allowServiceLogon: config.allowServiceLogon
134+
allowServiceLogon: config.allowServiceLogon,
135+
dependsOn: this.dependsOn
135136
});
136137
}
137138
},
@@ -464,6 +465,17 @@ var daemon = function (config) {
464465
value: config.execPath !== undefined ? require('path').resolve(config.execPath) : null
465466
},
466467

468+
/**
469+
* @property {Array} [dependsOn]
470+
* List of service names on which this service will be dependant on
471+
*/
472+
dependsOn: {
473+
enumerable: false,
474+
writable: true,
475+
configurable: false,
476+
value: config.hasOwnProperty('dependsOn') ? config.dependsOn : []
477+
},
478+
467479
/**
468480
* @method install
469481
* Install the script as a process.

lib/winsw.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ console.log({loc: 'winsw.js ~line 77', xml, config})
137137
});
138138
}
139139

140+
if(config.dependsOn.length > 0) {
141+
for (var i = 0; i < config.dependsOn.length; i++) {
142+
xml.push({ depend: config.dependsOn[i] });
143+
}
144+
}
145+
140146
// if no working directory specified, use current working directory
141147
// that this process was launched with
142148
xml.push({workingdirectory: config.workingdirectory || process.cwd()});

0 commit comments

Comments
 (0)