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

Windows Service Cannot Start (ERROR_SERVICE_REQUEST_TIMEOUT) #68

Open
fugolmere opened this issue Mar 17, 2018 · 14 comments
Open

Windows Service Cannot Start (ERROR_SERVICE_REQUEST_TIMEOUT) #68

fugolmere opened this issue Mar 17, 2018 · 14 comments

Comments

@fugolmere
Copy link

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

@takama
Copy link
Owner

takama commented Mar 18, 2018

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?

@acamilleri
Copy link
Contributor

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.

@fugolmere
Copy link
Author

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.

@neverland4u
Copy link
Contributor

neverland4u commented Mar 28, 2018

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.

@acamilleri
Copy link
Contributor

@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)

@llgoer
Copy link

llgoer commented Apr 18, 2018

get the same error:
Error: The service did not respond to the start or control request in a timely fashion.

@rusq
Copy link
Contributor

rusq commented Aug 30, 2018

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

@yi-ge
Copy link

yi-ge commented Aug 27, 2019

get the same error:
Error: The service did not respond to the start or control request in a timely fashion.

@Felixxxlz
Copy link

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

@CatchTheDog
Copy link

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.

@CatchTheDog
Copy link

help,what's the best solution?@krysennn

@mmeloni
Copy link

mmeloni commented May 2, 2020

Same problem here

@mmeloni
Copy link

mmeloni commented May 5, 2020

@neverland4u @fugolmere There are news on this?

@GwiYeong
Copy link

@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??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests