coreybutler / node-windows

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

Unreliable Events #164

Closed simon-robertson closed 7 years ago

simon-robertson commented 7 years ago

Running code cannot reliably determine the state of an installed service.

The start and stop events are not emitted when an installed service is started or stopped via a service manager. The only time they seem to be emitted is when the node-windows Service start() and stop() functions are called directly, or one the other functions such as uninstall() that stops the service.

For example, if an installed service stops automatically (e.g. if the node process exists) no stop event is emitted from the node-windows Service. Similarly, starting a stopped service via a service manager does not cause the the node-windows Service start event to be emitted.

coreybutler commented 7 years ago

This behavior is by design. Starting/stopping from the service manager would never have listeners attached, whereas starting/stopping from another node process would. The events are relative to the service, not the process. A process can stop, but the default action of the service is to remain active and attempt to restart the process.

Can you describe your use case in a little more detail? It sounds like you need an event to bubble up from the process to the service, but I'm unclear how you'd be handling that.

coreybutler commented 7 years ago

Closing due to age/lack of response.