Click here to Skip to main content
16,015,583 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error 1053: The service did not respond to the start or control request in a timely fashion - When trying to start the server service.



how to fix above error

What I have tried:

I have increased the timeout in registry but its not working
Posted
Updated 23-Jun-16 2:11am

It means your service is taking too long to start. You haven't posted any code so it's impossible to tell, but I'm going to take a guess that you have a sleep loop in the start event of your service. If that's the case then that is not how you write a service, the start event should only initialise it and create a thread that the actual "work" is done on, and the start event then needs to complete. Google how you write a service and you'll find starter templates.

If that isn't the issue you'll need to post some relevant code.
 
Share this answer
 
v2
Comments
Member 10530640 24-Jun-16 2:49am    
protected override void OnStart(string[] args)
{
//System.Diagnostics.Debugger.Launch();
Utilities.OverrideAppName = "SpanService";
Management.LoadConfiguration();

Logging.LogUnitInfo("Span", new { OnStart = "OnStart" }, "SpanWindowsService: OnStart Called");

ServiceWorkerThread();

Logging.LogUnitInfo("Span", new { OnStart = "OnStart" }, "SpanWindowsService: OnStart: SpanService started.");
}

///
/// The method performs the main function of the service. It runs on
/// a thread pool worker thread.
///

public void ServiceWorkerThread()
{
Logging.LogUnitInfo("Span", new { ServiceWorkerThread = "ServiceWorkerThreadStart" }, "SpanWindowsService: ServiceWorkerThread Called");

try
{
if (spanServiceHost != null)
{
spanServiceHost.Close();
Logging.LogUnitInfo("Span", new { SpanServiceHost = "SpanServiceHost" }, "SpanWindowsService: ServiceWorkerThread: SpanService hosted closed.");
}

Task spanTask = new Task(SpanFileProcessor);
spanTask.Start();
spanTask.Wait();
if (spanTask.IsCompleted)
{
Logging.LogUnitInfo("Span", new { SpanTask = "SpanTaskComplete" }, "SpanWindowsService: ServiceWorkerThread: SpanService task ic completed");
spanTask.Dispose();

Logging.LogUnitInfo("Span", new { SpanServiceHost = "SpanServiceHostStart", ServiceHostStartAt = DateTime.Now }, "SpanWindowsService: ServiceWorkerThread: SpanService hosting started");
spanServiceHost = new ServiceHost(typeof(SpanService));
new SpanService();
spanServiceHost.Open();

Logging.LogUnitInfo("Span", new { SpanServiceHosted = "SpanServiceHosted", ServiceHostedAt = DateTime.Now }, "SpanWindowsService: ServiceWorkerThread: SpanService hosted successfully.");
}
else
{
Logging.LogUnitInfo("Span", new { SpanTask = "SpanTaskInComplete", TaskStatus = spanTask.IsCompleted }, "SpanWindowsService: ServiceWorkerThread: Span task not completed.");
}

Logging.LogUnitInfo("Span", new { ServiceWorkerThread = "ServiceWorkerThreadEnd" }, "SpanWindowsService: ServiceWorkerThread finished");
}
catch (Exception ex)
{
Logging.LogUnitInfo("Span", new { Error = ex.Message, Exception = ex }, "SpanWindowsService: ServiceWorkerThread is failed");
}
}
F-ES Sitecore 24-Jun-16 4:18am    
You do the work on a separate task which is good, but after starting the task you wait for it to finish. So basically your start code doesn't just start the task off, it effectively does the task also. The start event needs to complete within a certain timeframe, it's really just for initialising your code, you shouldn't be doing any work on it. So rather than waiting for the task to finish, you should handle the ending of the task via an event.
You may also have put your real startup code in that start event. Your processing should be in a separate thread. Your main thread just responds to events. In the startup case, sleep is not a "bad" thing if it is short and in a loop to respond to the service manager that you are still working on it. (Obviously the sleep should be a timeout on a semaphore that is signaled when the startup has completed.)

A possibility is again to have your processing in another thread and have the start event just respond "Yup... got'r done!".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900