Replies: 1 comment 2 replies
-
The scenario you're presenting is a paradox. A running script cannot handle its own close event, because it will no longer be running once it is closed. However; I believe the real intent of your question is to address intentional shutdowns and monitoring existing background services. It is possible to control the background service after it is created, i.e. intentionally shutdown or start the service as shown in this example. Node-windows is not an external process monitor though. A node-windows service will monitor itself to perform automatic restarts, but the primary goal of this tool is to integrate with the windows task/service system. This allows other common tools (like Nagios, Windows Systems Center, etc) to monitor the services. If you want to monitor the background service and respond to close events from Node, you'll need a separate process to do that. That is not something node-windows is designed to do. |
Beta Was this translation helpful? Give feedback.
-
Are there any working examples or best practices on how to use node-windows? The documentation is theoretical and doesn't explain specific how and where to use it. What I can understand from the documentation you create a separate script with a service object that handles installing and uninstalling and just refers to the actual script that will be the service. But what is lacking in the documentation is how do you in the running script handle events like when the service get a closing event. Should you create the exact same service object to be able to handle that?
I feel like I need to use node-windows in two places, the windows service script for actual handling the running service, and in the install script to handle the installation of the service. But the documentation doesn't explain how to use it, only what functions it have and what they do. But not how you set up these two scenarios...
Beta Was this translation helpful? Give feedback.
All reactions