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 ); } }

Replies are listed 'Best First'.
Re^12: Win32::Daemon service doesn't reach RUNNING state
by Anonymous Monk on Oct 04, 2019 at 00:34 UTC

    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.

    Thats the thing about sleep, you only get to ask what you want, doesn't mean system will give you that 100% of the time -- what you do get 80%-98% of the time is exactly what you asked for, in addition to not wasting CPU cycles by emulating "sleep"