AnyEvent-Watchdog
view release on metacpan or search on metacpan
Watchdog/Util.pm view on Meta::CPAN
syswrite $C, $AUTORESTART ? "\x01" : "\x00";
}
=item AnyEvent::Watchdog::Util::heartbeat [$interval]
=item use AnyEvent::Watchdog heartbeat => $interval
Tells the supervisor to automatically kill the program if it doesn't
react for C<$interval> seconds (minium 1, maximum 255, default 60) , then
installs an AnyEvent timer the sends a regular heartbeat to the supervisor
twice as often.
Exit behaviour isn't changed, so if you want a restart instead of an exit,
you have to call C<autorestart>.
The heartbeat frequency can be changed as often as you want, an interval
of C<0> disables the heartbeat check again.
=cut
Watchdog/Util.pm view on Meta::CPAN
$interval = 60 unless defined $interval;
$interval = 0 if $interval < 0;
$interval = 255 if $interval > 255;
$interval = int $interval;
syswrite $C, "\x03" . chr $interval
if $C;
$HEARTBEAT_W = AE::timer 0, $interval * 0.5, sub {
syswrite $C, "\x04"
if $C;
};
}
=item AnyEvent::Watchdog::Util::on_exit { BLOCK; shift->() }
Installs an exit hook that is executed when the program is about to exit,
while event processing is still active to some extent.
( run in 0.927 second using v1.01-cache-2.11-cpan-49f99fa48dc )