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

Service did not respond to the start or control request in a timely fashion #109

Open
pmunshi007 opened this issue Sep 28, 2018 · 10 comments

Comments

@pmunshi007
Copy link

pmunshi007 commented Sep 28, 2018

I know this issue was raised before but currently I am also facing the same issue and I have tried all the solutions provided in #13 but no luck. Most annoying part here is the code base is same in master branch and my current branch. I just added few arguments to pass while running the program however the code to install/start/stop/uninstall service is the same. I am able to install and run service from master branch code base. But I am getting below error while trying to start service via command-line in my current branch. I am running this program in administrator terminal and also my basedirectory path does not contain space.

System.InvalidOperationException: Cannot start service testService on computer '.'. ---> System.ComponentModel.Win32Exception: The service did not respond to the start or control request in a timely fashion
         --- End of inner exception stack trace ---
         at System.ServiceProcess.ServiceController.Start(String[] args)
         at PeterKottas.DotNetCore.WindowsService.ServiceRunner`1.StartService(HostConfiguration`1 config, ServiceController sc)
         at PeterKottas.DotNetCore.WindowsService.ServiceRunner`1.UsingServiceController(HostConfiguration`1 config, Action`2 action)
         at PeterKottas.DotNetCore.WindowsService.ServiceRunner`1.Run(Action`1 runAction)
info: *.Service.Program[0]
      Return value from Run function -1

Even If I try to run the installed process from user interface it gives me below error.

windows could not start the service on local computer
error 1053 the service did not respond to the start or control request in a timely fashion

I am using 2.0.8 version of PeterKottas.DotNetCore.WindowsService library.
What could be the reason here?

@pmunshi007
Copy link
Author

I am having same error with the latest version also 2.0.9 version of PeterKottas.DotNetCore.WindowsService library.

@andreibulatov
Copy link

andreibulatov commented Oct 3, 2018

I have this trouble too

upd
solution
I rewrote Main method, replaced all slowly reflection
before
ServiceRunner<SomeService>.Run(config =>{

@ka4ep
Copy link

ka4ep commented Oct 4, 2018

Quite a common problem. My solution was to implement an own descendant of MicroService class where I've started a RunOnceTimer with all the initialization, IoC with assembly scanning, Akka, Nancy in a callback method. Not before or during Run(). Basically, you start a separate thread (like timer) and immediately tell Windows you're all done loading.

@kalimist123
Copy link

Im having this problem too. @Apostol59 could you elaborate on your solution?

@andreibulatov
Copy link

@kalimist123, no problem, bro.
I had di container configuration in method main, container cofiguration was be relocated in OnStart.

Main method must contains minimum of operations before OnStart.

//from example
void Main()
{
//old di configuration
ServiceRunner<ExampleService>.Run(config =>
{
	var name = config.GetDefaultName();
	config.Service(serviceConfig =>
		{
			serviceConfig.ServiceFactory((extraArguments, microServiceController) =>
		{
			return new ExampleService();
		});
		serviceConfig.OnStart((service, extraArguments) =>
		{
//now di configuration
			Console.WriteLine("Service {0} started", name);
			service.Start();
		});
...
}
}

@kalimist123
Copy link

@Apostol59 thank you

@justintoth
Copy link
Contributor

I was running into this error as well, however I was hitting it immediately when starting the service, it wasn't waiting 30 seconds. The issue was that I was using Network Service instead of Local System to run the windows service, must have been some sort of permissions issue...

@sagar-patel-sls
Copy link

@Apostol59

I am having same error with the latest version of PeterKottas.DotNetCore.WindowsService library.
Above your solution didn't work for me

can you please help me..

@andreibulatov
Copy link

@sagar-patel-sls
Hi, I'm not a maintainer.
May be @PeterKottas can help you, but, will be need more details, I think)

@sagar-patel-sls
Copy link

Hii @PeterKottas

I am having same error with the latest version of PeterKottas.DotNetCore.WindowsService library.
Above your solution didn't work for me

can you please help me..

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

6 participants