coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.83k stars 356 forks source link

07/02/2023: Dependent on another service #335

Closed countnazgul closed 1 year ago

countnazgul commented 1 year ago

Is your feature request related to a problem? Please describe.

Not sure if its possible atm but want to make my service dependant on another windows service. I have a case to interact with a rest api (3rd party Windows service) and register some notifications with it. All is good until the 3rd party windows service is restarted. When this happens im loosing all the registered notifications and my service will no longer receive updates. So i was thinking if its possible to make my service dependant on the other Windows service and when it is restarted to restart my service as well. And then i can re-create the notifications again.

Describe the solution you'd like Something like: have another property in the register object - dependsOn (or something). Where windows service name(s?) can be specified.

Describe alternatives you've considered Have another Windows service (c#) thats is listening for the 3rd party windows service state change. Whenever the state is changed it pings the main service (dedicated endpoint) to re-create the notifications.

I've found that such dependency can be created via sc config ServiceA depend= ServiceB but it will be nice to have it as configuration of my service. Easier to maintain ... i think :)

Additional context n/a

Please use the reactions to cast a vote in favor of or against this feature suggestion »
coreybutler commented 1 year ago

I love this idea, but I won't have time to implement something like this anytime soon. I'd be open to a PR if anyone wants to take a crack at it.

countnazgul commented 1 year ago

Ive added dependsOn in my fork. And it seems to work 😄 Before i open PR, can someone have a quick look at my fork? Just to verify that im following the rules https://github.com/countnazgul/node-windows/commit/3bacaadcd65e6209c60c2315f3a707f6d580161b

coreybutler commented 1 year ago

Thanks @countnazgul. I commented on your fork.

countnazgul commented 1 year ago

Thanks @coreybutler. You comment makes sense.

Ive code is now converted to the native for loop https://github.com/countnazgul/node-windows/commit/b2c1b497f781240a5561338fa2744465f2b202c1

AcureroAdrian commented 11 months ago

This featured is not available in npm package, please upload that.