Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace nssm restart by powershell commands #282

Merged
merged 1 commit into from
Mar 18, 2016

Conversation

kamaradclimber
Copy link
Contributor

Very frequenty nssm commands (stop and start) fail because the service
gets into STOP_PENDING or START_PENDING state.
powershell commandlets such as restart-service have the good taste to
wait for the service to stop/start completely.

Very frequenty nssm commands (stop and start) fail because the service
gets into STOP_PENDING or START_PENDING state.
powershell commandlets such as restart-service have the good taste to
wait for the service to stop/start completely.
@johnbellone
Copy link
Contributor

I don't know too much about nssm to be honest. I did a little searching on the page and it seems like there are configurations where you can tweak some changes.

http://nssm.cc/usage

@johnbellone
Copy link
Contributor

/cc @Ginja since he wrote the Windows service provider.

@Ginja
Copy link
Contributor

Ginja commented Mar 18, 2016

I haven't seen this too much in our environment. Have you tried playing with the restart delay option of NSSM, @kamaradclimber?

As of version 2.22, nssm can apply a mandatory delay between restarts of the application. This could be used, for example, to run a command at regular intervals such as an hourly batch script.

To specify a restart delay, create an integer (REG_DWORD) value HKLM\System\CurrentControlSet\Services\servicename\Parameters\AppDelay and set it to the number of milliseconds to wait between restarts.

The service will report its state as Paused while waiting for the next restart. Sending it a Continue control will temporarily cancel the delay and trigger a restart immediately.

Please see the section on restart throttling below for notes on how nssm works when both throttling and restart delays are configured.

@kamaradclimber
Copy link
Contributor Author

thanks @Ginja for you reply. As far as I understand the restart delay option it only deals with a delay between the service stop and the moment nssm tries to start it again.

In my case, a simple restart command send to nssm is causing the state.

It seems to be due to consul taking some time to stop (writing some information to disk) that might be long (a few seconds for a 2k node cluster) and nssm does not wait properly for process termination thus declaring the service as "stop pending".

Apparently powershell commandlets handle this correctly.

@Ginja
Copy link
Contributor

Ginja commented Mar 18, 2016

@kamaradclimber thanks for the clarification, that makes sense. I don't manage that large of a fleet in one Consul data centre, which probably would explain why I never ran into this issue. I just tested using those cmdlets locally & it looks like it'll work fine with NSSM.

I'd say go ahead & merge this, @johnbellone.

johnbellone added a commit that referenced this pull request Mar 18, 2016
Replace nssm restart by powershell commands
@johnbellone johnbellone merged commit 3c3e75d into sous-chefs:master Mar 18, 2016
@kamaradclimber
Copy link
Contributor Author

kamaradclimber commented Mar 19, 2016 via email

@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants