On 5/22/06, Berger, Daniel <Daniel.Berger qwest.com> wrote:
> I didn't see it because your 'log' method was
defined outside of your
> daemon class. In fact, your script works just fine
once you move those
> methods within the Daemon class itself. Attached is
the script I'm
> using. Here was the output:
>
> 2006-05-22 11:58:09 - ** Dead Simple Service
starting...
>
> 2006-05-22 11:58:11 - ** Done initialization.
>
> 2006-05-22 11:58:11 - Entering Service Main
> do nothing!
>
> 2006-05-22 11:58:49 - Leaving Service Main
>
> (I added some spaces there since Outlook is joining
them into a single
> string for some reason).
>
> Hope that helps.
>
> Dan
Daniel, you tried more than 1 start/stop cycles?
In the first run, everything worked ok, but several tries
after it,
showed that it works "sometimes" and other
don't. (no matter if you
left the service running for 1 second or 10 minutes)
Even with these modifications, not always work.
I find useless the service_stop method... sometimes it work,
other
don't. Moving the cleanup code from it to the service_main
method
(after the loop) also not always work, if the method is in
the wrong
point in time (like not evaluating state == RUNNING in that
exact
moment), the thread that runs service_main get terminated by
the
service.so
If you see the attached version, service_stop will try to
raise the
Interrupt exception so the runner thread gets terminated.
that won't happen...
if you move these 2 lines to service_main and comment
service_stop, it
will work.
But if you add code that need more time to of execution, the
thread
will get terminated:
def service_main
log "Entering Service Main"
while state == RUNNING
sleep 1
end
log "Exiting main loop."
runner.raise Interrupt
# slower cleanup...
sleep 3
log "Leaving Service Main"
end
"Leaving Service Main" will never show up in the
log, nor will wait 3 seconds.
Maybe I don't get it, but I created a framework for service
in
FreeBASIC and also C++, with custom options for the events
(onInit,
Main, onStop, onShutdown).
And these worked ok, but found that service.c:Service_Ctrl
first
execute the associated method with the EventArray and then
set the
service in a PENDING state, which 2 microseconds later get
terminated
by the evaluation of the controlcode and the set of
StopEvent...
So: slow code in service_stop make Service Manager think
your service
hang. Evaluating state in service_main is useless because
you need the
right timming (or luck) to evalaute it when was set, lucky
enough
don't get killed by the StopEvent raised...
I'm getting it wrong?
Please excuse my poor english (I try harder to express
clearly what is
happening) but english is not my native/natural language.
Regards,
--
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard
effort,
which is the price which all of us must pay to achieve any
goal that
is worthwhile.
Vince Lombardi
_______________________________________________
win32utils-devel mailing list
win32utils-devel rubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel |