Hi Simon,
I don't know much about nssm so I cannot advise on that.
However, the windows-service module [1] does this in a different way,
firstly the windows service is hosted in node, that is the node binary (and
your node program) is the service process, and your script gets told when
the service has received a stop request:
var service = require ("windows-service");
var logStream = fs.createWriteStream ("my-service.log");
service.run (logStream, function () {
console.log ("stop request received");
service.stop (); // stop() will call process.exit()
});
Steve
[1]: https://npmjs.org/package/windows-service
On Thursday, 28 February 2013 08:34:42 UTC, Simon Rijk wrote:
>
> Do you know what signal the main NodeJS process receives when a Windows
> service is stopped?
>
> I am using NSSM to install my NodeJS process as a Windows service. But
> when I stop the Windows service,* the child processes keep running*.
>
> Do you know how to solve this?
>
> Op dinsdag 13 maart 2012 05:21:47 UTC+1 schreef CoolAJ86 het volgende:
>>
>> nssm.exe, actually.
>>
>> And yes, I do want the service to be restarted.
>> On app startup there's a loop that requires all modules in a directory.
>>
>> Each time a new module in installed, the service should exit.
>> It should then be restarted, rereading all of the modules (including the
>> new one).
>>
>> When running the app in the foreground it works as expected.
>> When running the app as a service it doesn't exit.
>>
>> I'll figure it out tomorrow.
>>
>> AJ ONeal
>>
>>
>> On Mon, Mar 12, 2012 at 7:46 PM, Bert Belder <[email protected]> wrote:
>>
>>> On Mar 13, 12:37 am, AJ ONeal <[email protected]> wrote:
>>> > It appears that `process.exit()` doesn't not work on windows when a
>>> node
>>> > app is running as a service.
>>> >
>>> > Is this a bug? Or simply not possible?
>>> > Does anybody have a workaround?
>>> >
>>> > I'm thinking maybe I can exec `net nodeapp restart` after calling
>>> > `process.exit()`
>>> >
>>> > I'm working on a self-updating feature and I want my service to quit
>>> itself
>>> > and be automatically restarted.
>>> >
>>> > AJ ONeal
>>>
>>> I assume that you are using some sort of service wrapper (like
>>> srvany.exe), since node.exe itself cannot run as a service at the
>>> moment. It could be that your service wrapper is just restarting your
>>> node process when it exits. It seems unlikely to me that
>>> process.exit() would just be ignored.
>>>
>>> You probably should send a service stop signal, with something similar
>>> to:
>>> `require('child_process').spawn('sc', ['stop', 'myservicename']);`
>>>
>>> --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>
>>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.