Service takes 1 min 34 sec to start

S

Sam

Service properties
------------------
Log On As: LocalSystem
Logon account has full admin privileges.


OnStart() routine
-----------------
{
EventLog->WriteEntry ("Commencing..."); .... A
Spawn1()
Spawn2()
EventLog->WriteEntry ("Completing..."); .... B
}

In Automatic mode
-----------------
Service takes 1 min 34 sec to start (Time from A to B as recorded in
the Event Viewer). Service Controller Manager complains @ 1 min 30 sec
that "The xxxxx service hung on starting", but the service does start
up eventually and all is well.

In Manual startup mode
----------------------
Service starts in 4 seconds


Details
-------
Spawn1() starts a managed remoting server
Spawn2() starts a process inside a real time kernel (RTX). The kernel
itself starts "on demand", and is a manual service. I've listed this
kernel as a dependency for my service.

Question
--------
1. How do I debug this and reduce the time in Automatic Startup mode?
2. Why doesnt the SCM throw an exception even though my service
violates the 30 second OnStart rule?

Thank you.
Sam
 
W

Wayne

I'm assuming it complains at start up of the machine, I've not done much
with services in .net, but is it possible you need to add the Eventlog
service as a dependent of yours since you are writing to the event log in
your start up? This may cause your service to wait it's starting till the
eventlog is fully started.

--
Thanks
Wayne Sepega
Jacksonville, Fl


"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein
 
W

Willy Denoyette [MVP]

Anything that takes more than 30 seconds should be done on a separate
thread. So what you sould do is spawn a new thread and execute Spawn1 and
Spawn2 on that thread.

Willy.
 
I

Indie Pop

Sam said:

When you say "Automatic" you are saying after a reboot ?

So, you are probably waiting for the machine to reboot all of its internal
systems so that you can run the processes in "Spawn()".

What I do is put the processes I want to run in a Timer_Tick method and set
an interval, like, say 120000 ms. So the first time the process runs is
120000ms after start, and then every 120000 ms afterwards ( if thats what
you want ).
 
G

Guest

Sam,

You should not execute code in the main service thread. You should instead
spawn a thread that does the initialization. I think that the OnStart method
from ServiceBase should be non-blocking.

TT
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top