http://qs1969.pair.com?node_id=11100943


in reply to Re^10: Win32::Daemon service doesn't reach RUNNING state
in thread Win32::Daemon service doesn't reach RUNNING state

Ran into yet another issue. The request for 5 second intervals is not honored on the systems in question. Intervals can be 20 seconds or more apart. Here is a mod to make the execution happen closer to on time.

our $startTime = time(); # put this line BEFORE use Win32::Daemon; ... ... ... our $t; sub Callback_Running { my ($Event, $Context) = @_; $t = $startTime if ! $t; if (SERVICE_RUNNING == Win32::Daemon::State()) { if (time() - $t >= $iSleep * 60) { print $fh "Checking in.\n"; # Do work here $t = time(); } # These two lines are needed for both versions $Context->{last_state} = SERVICE_RUNNING; Win32::Daemon::State( SERVICE_RUNNING ); } elsif (SERVICE_PAUSED == Win32::Daemon::State()) { # Without this, pause/continue fails $Context->{last_state} = SERVICE_PAUSED; Win32::Daemon::State( SERVICE_PAUSED ); } }