Skip to content

The packaged NSSM version tight loops on failure #9

Closed
fingersdancing opened this Issue Dec 11, 2012 · 2 comments

2 participants

@fingersdancing

If the application is exiting unsuccessfully process.exit(1) the service will restart immediately. This is a different behaviour to what the nssm site states.

"The first restart will be attempted with no delay. If the restarted application continues to exit before running for the threshold amount of milliseconds, nssm will pause for at least 2000 milliseconds, doubling the pause time for each subsequent failure. The maximum time it will pause is 256000 milliseconds, around four minutes. The delay counter is reset when the service successfully runs for at least the threshold time."

See http://nssm.cc/usage Restart throttling

I download nssm from the nssm.cc (version 2.16 64 bit) and it worked as described.

The packaged version is 2.11 (not sure if it is 64/32 bit).

I'm running Windows 7 Enterprise SP1 (64 bit)

@jfromaniello
Owner

Hi @fingersdancing I just updated to version 2.16 (winser@0.0.13).

please, can you try this and tell me if it works as expected?

Its still using the 32bit version always, but I think I could put the two binaries and detect the platform.

@fingersdancing

Thanks for the quick action @jfromaniello .

I thought I pin the issue down to the version of nssm.exe but what it appears to be is that my process.exit(1) which is wrapped as so setTimeout(function(){ process.exit(1); }, 1000); I do this so other parts of my application can finish doing whatever they are doing cleanly.

Even though nssm is suppose to manage process which exit in less than 1500 ms with the "Restart throttling" it appears a timeout of 1000ms is too long. I reduced the timeout to 500ms and the throttling worked as expected.

I then went back to the timeout of 1000ms but set the HKLM\System\CurrentControlSet\Services\servicename\Parameters\AppThrottle (See http://nssm.cc/usage Restart Throttling) to 2000ms. The throttling then worked as expected. I then investigated how long my application was running before it exited and it varied from 1400-1500ms so it was getting too close to the default setting of 1500ms. This is the core reason why it appeared my application "appeared" to be tight looping.

So in summing up a developer needs think carefully of about the "AppThrottle" value as the default 1500ms may be too short.

Also @jfromaniello my environment is 64bit so the detection sounds like a great feature :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.