… | |
… | |
118 | |
118 | |
119 | } elsif ($cmd eq chr 3) { |
119 | } elsif ($cmd eq chr 3) { |
120 | sysread $P, my $interval, 1 |
120 | sysread $P, my $interval, 1 |
121 | or last; |
121 | or last; |
122 | |
122 | |
123 | $heartbeat = ord $interval |
123 | $heartbeat = ord $interval; |
124 | unless defined $heartbeat; |
|
|
125 | |
124 | |
126 | } elsif ($cmd eq chr 4) { |
125 | } elsif ($cmd eq chr 4) { |
127 | # heartbeat |
126 | # heartbeat |
128 | # TODO: should only reset heartbeat timeout with \005 |
127 | # TODO: should only reset heartbeat timeout with \005 |
129 | |
128 | |
… | |
… | |
269 | twice as often. |
268 | twice as often. |
270 | |
269 | |
271 | Exit behaviour isn't changed, so if you want a restart instead of an exit, |
270 | Exit behaviour isn't changed, so if you want a restart instead of an exit, |
272 | you have to call C<autorestart>. |
271 | you have to call C<autorestart>. |
273 | |
272 | |
274 | Once enabled, the heartbeat cannot be switched off. |
273 | The heartbeat frequency can be changed as often as you want, an interval |
|
|
274 | of C<0> disables the heartbeat check again. |
275 | |
275 | |
276 | =cut |
276 | =cut |
277 | |
277 | |
278 | sub heartbeat(;$) { |
278 | sub heartbeat(;$) { |
279 | my ($interval) = @_; |
279 | my ($interval) = @_; |
… | |
… | |
302 | Carp::croak "AnyEvent::Watchdog: '$_' is not a valid import argument"; |
302 | Carp::croak "AnyEvent::Watchdog: '$_' is not a valid import argument"; |
303 | } |
303 | } |
304 | } |
304 | } |
305 | } |
305 | } |
306 | |
306 | |
|
|
307 | =back |
|
|
308 | |
307 | =head1 SEE ALSO |
309 | =head1 SEE ALSO |
308 | |
310 | |
309 | L<AnyEvent>. |
311 | L<AnyEvent>. |
310 | |
312 | |
311 | =head1 AUTHOR |
313 | =head1 AUTHOR |