Windows Service Cannot Start (ERROR_SERVICE_REQUEST_TIMEOUT)
fugolmere opened this issue · comments
Problem
Attempting to start windows service results in a long pause and the following error returned:
ERROR_SERVICE_REQUEST_TIMEOUT: The service did not respond to the start or control request in a timely fashion.
I believe this problem is caused by the fact that that the service control manager is expecting a "status" to be returned from the underlying executable it's managing:
The SCM starts the process and waits until either the child process exits (indicating a failure) or reports the SERVICE_RUNNING status.
source: https://msdn.microsoft.com/en-us/library/windows/desktop/ms685990(v=vs.85).aspx
Solution
If sc.exe
is desired to be used over nssm.exe
then I believe a more complex solution is required. Specifically a "SERVICE_RUNNING" status will need to be returned back to the windows service control manager.
Take a look at the following that appears to effectively perform this action:
https://github.com/kardianos/service/blob/0ab6efe2ea51f0531a8ceaaa33416b3aab844c28/service_windows.go#L167
Thank you @fugolmere, your feedback is very appreciated. I have not possibility to test all that related with Windows. @krysennn Could you handle this issue?
Hi,
My bad ... i will test the code with this: https://github.com/martinlindhe/wmi_exporter/blob/master/exporter.go
I don't see the func (https://github.com/martinlindhe/wmi_exporter/blob/cede2675657f234833d2a6760743e5f513562de1/exporter.go#L257) about started service.. so i didn't get error during my test.
I will fix it ASAP.
FYI, I have a fix for this. I should be able to submit a pull request as early as later tonight or tomorrow. I'll explain further details in the pull request comment.
Hi @krysennn, a PR has been created to make windows version daemonization work. Pls review.
BTW, golang.org/x/sys/windows
is necessity of this solution. If the sub-repo cannot be accepted, pls close that PR. Thx.
@neverland4u i think it's ok, i don't have test it ATM.
BTW, golang.org/x/sys/windows is necessity of this solution. If the sub-repo cannot be accepted, pls close that PR. Thx.
I think no, it's not the best solution.
There are two type of use:
1- You create service for your application (service status needed)
2- You create service for other application (service status need in your other application)
get the same error:
Error: The service did not respond to the start or control request in a timely fashion.
Hi team,
Observed this on 2008 and win 10 - just used the example from the repository.
$ go version
go version go1.11 darwin/amd64
master branch
C:\Users\rusq\go\src\github.com\takama\daemon\examples>examples.exe start
Starting My Echo Service: [←[31mFAILED←[0m]
Error: The service did not respond to the start or control request in a timely fashion.
Same happens when trying to control the service with services.msc
get the same error:
Error: The service did not respond to the start or control request in a timely fashion.
get the same error:
Error: The service did not respond to the start or control request in a timely fashion.
however another project is ok, can't find the difference
go version:go version go1.13.3 windows/amd64
os: Microsoft Windows [Version 10.0.18362.535]
run cron job example with args 'start' and return error: The service did not respond to the start or control request in a timely fashion.
help,what's the best solution?@krysennn
Same problem here
@neverland4u @fugolmere There are news on this?
@acamilleri @neverland4u @fugolmere
I also get the same error:
Error: The service did not respond to the start or control request in a timely fashion.
any update for this??