coreybutler / node-windows

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

Feature: set ID and PID option #199

Closed oliveirag closed 6 years ago

oliveirag commented 6 years ago
 var svc = new Service({
   pid: 88888,
   name:'Hello World',
   description: 'The nodejs.org example web server.',
   script: 'C:\\path\\to\\helloworld.js')
 });

It would be useful for killing the process. Setting the id of the service instead of just calling it name.exe would also be good.

coreybutler commented 6 years ago

There is no way to set the PID using the underlying winsw library, so it's not possible to set it. A feature to retrieve the PID from the install event would be possible, but I'm not going to have time to add that anytime soon (PR welcome).

If your service happens to be using a port (i.e. a web/net server), another possible option would be porthog. This will retrieve the PID for a process on any given port.