in reply to Running callback stops working in Win32::Daemon

Hello SimonPratt, and welcome to the Monastery!

You don’t say which version of Win32::Daemon you’re running. I see from the documentation for the latest version (20131206):

Timer/Running Callbacks:

Starting with build 20080321 the "running" callback is deprecated and replaced with the "timer" callback. Scripts should no longer test for a state of SERVICE_RUNNING but instead check for the state of SERVICE_CONTROL_TIMER to indicate whether or not a callback has occurred due to a timer.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

  • Comment on Re: Running callback stops working in Win32::Daemon

Replies are listed 'Best First'.
Re^2: Running callback stops working in Win32::Daemon
by SimonPratt (Friar) on Jan 24, 2014 at 16:02 UTC

    Hi, Athanasius

    Sorry, I'm not sure this is actually going to help.

    Specifically, further on in the docs, it states:

    ...registers for the "running" callback it will continue to work as expected: timer expiration results in a callback to the subroutine registered for the "running" callback passing in a value of SERVICE_RUNNING.

    Now, I have tested switching the running callback registration to use a timer callback registration and the actual behaviour doesn't appear to match what is defined in the documentation (in that the STATE eq SERVICE_RUNNING, regardless of whether I register a timer callback or a running callback). Instead of the STATE changing, the EVENT passed to the function is changed from SERVICE_CONTROL_RUNNING to SERVICE_CONTROL_TIMER, which kind of makes sense.

    If you comment out the return and the check in callbackRunning in the example I supplied (lines 85 and 87), you'll (eventually) see that callbackRunning simply stops being called in one of the services after several hours with both copies of the service running, although if you only have one copy installed and running, it will just keep running.

    I'll test it now with a timer callback registered instead of a running callback and let you know how it goes.

    Thanks for your help so far though, it is very much appreciated.

Re^2: Running callback stops working in Win32::Daemon
by SimonPratt (Friar) on Jan 24, 2014 at 14:23 UTC

    Heh, I feel a bit stupid now :-)

    Thanks for your help, I'm sure that will put me on the right track.

    In answer to your question, I'm still on 20110117, however the changelog doesn't appear to address anything more serious than typos and documentation fixes since that version anyway (although hopefully these changes mean that maintenance of this library will pick up again).