Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected status SERVICE_START_PENDING in response to START control

When trying to restart an existing windows service via NSSM, I randomly get the below message which is written to the error log/error output. Any ideas on how to rectify? Ideally, accept as a valid response.

Unexpected status SERVICE_START_PENDING in response to START control

like image 453
johnnyboy Avatar asked Jan 27 '15 13:01

johnnyboy


People also ask

What does service_start_pending mean?

You will get "SERVICE_START_PENDING" if the the service takes too long to start (it means the service hasn't told Windows that it's started yet). "Too long" is up to the application issuing the start request. In the case of NSSM this appears to be very short, so if your system is under load the service is taking longer to start than NSSM expects.

How to restart a service after it has failed?

If the service fail: In my opinion, there is a potential workaround,by setting up a service recovery option in the service properties. Then select "Run a program" when the service failed. Then code a batch to get the PID of this service and kill it, then use NSSM to start it again.

Why can't I start a program from a service?

It is highly probable that the service has bug and hang, fail, or take too much time to stop properly. Which raise issue when try to start it. If the service fail: In my opinion, there is a potential workaround,by setting up a service recovery option in the service properties. Then select "Run a program" when the service failed.

What to do when the service stops working?

1. If the service is stopping for reasons other than someone stopping it or the CAD, look into why this is happening and what else may be going on with the system when you see this occur (look for a trend). 2.


1 Answers

I believe that this issue was caused by the service itself.


It is highly probable that the service has bug and hang, fail, or take too much time to stop properly. Which raise issue when try to start it.


If the service fail: In my opinion, there is a potential workaround,by setting up a service recovery option in the service properties. Then select "Run a program" when the service failed. Then code a batch to get the PID of this service and kill it, then use NSSM to start it again.

In this batch you may use "SC query" command to check the service status:

C:\Windows>sc query "MyService" | find "STATE"
    STATE              : 3  STOP_PENDING

Note that if you use NSSM only to hide the windows, you may achieve the same goal with the Task Scheduler only.

In the "General" tab on task property. If you select "Run whether user is logged on or not", this will run from session 0 which won't show any window to you.

Then what you need to do on your scheduled task are, to kill / restart the target process itself as you do now. This will work more robustly.


If the service is not an official windows service but more an EXE program file (dev on your side) then converted to a services with NSSM, there is a high chance of failure. It could be better to rewrite/recompile the program as an actual Windows service.

like image 129
A STEFANI Avatar answered Oct 03 '22 00:10

A STEFANI