… | |
… | |
55 | |
55 | |
56 | sub enabled() { |
56 | sub enabled() { |
57 | $AnyEvent::Watchdog::ENABLED |
57 | $AnyEvent::Watchdog::ENABLED |
58 | } |
58 | } |
59 | |
59 | |
60 | =item AnyEvent::Watchdog::restart_in [$timeout] |
60 | =item AnyEvent::Watchdog::Util::restart_in [$timeout] |
61 | |
61 | |
62 | Tells the supervisor to restart the process when it exits (enable |
62 | Tells the supervisor to restart the process when it exits (enable |
63 | autorestart), or forcefully after C<$timeout> seconds (minimum 1, maximum |
63 | autorestart), or forcefully after C<$timeout> seconds (minimum 1, maximum |
64 | 255, default 60). |
64 | 255, default 60). |
65 | |
65 | |
… | |
… | |
87 | |
87 | |
88 | # now make sure we dont' send it any further requests |
88 | # now make sure we dont' send it any further requests |
89 | our $OLD_C = $C; undef $C; |
89 | our $OLD_C = $C; undef $C; |
90 | } |
90 | } |
91 | |
91 | |
92 | =item AnyEvent::Watchdog::restart [$timeout] |
92 | =item AnyEvent::Watchdog::Util::restart [$timeout] |
93 | |
93 | |
94 | Just like C<restart_in>, but also calls C<exit 0>. This means that this is |
94 | Just like C<restart_in>, but also calls C<exit 0>. This means that this is |
95 | the ideal method to force a restart. |
95 | the ideal method to force a restart. |
96 | |
96 | |
97 | =cut |
97 | =cut |
… | |
… | |
130 | } |
130 | } |
131 | |
131 | |
132 | syswrite $C, $AUTORESTART ? "\x01" : "\x00"; |
132 | syswrite $C, $AUTORESTART ? "\x01" : "\x00"; |
133 | } |
133 | } |
134 | |
134 | |
135 | =item AnyEvent::Watchdog::heartbeat [$interval] |
135 | =item AnyEvent::Watchdog::Util::heartbeat [$interval] |
136 | |
136 | |
137 | =item use AnyEvent::Watchdog heartbeat => $interval |
137 | =item use AnyEvent::Watchdog heartbeat => $interval |
138 | |
138 | |
139 | Tells the supervisor to automatically kill the program if it doesn't |
139 | Tells the supervisor to automatically kill the program if it doesn't |
140 | react for C<$interval> seconds (minium 1, maximum 255, default 60) , then |
140 | react for C<$interval> seconds (minium 1, maximum 255, default 60) , then |
… | |
… | |
170 | syswrite $C, "\x04" |
170 | syswrite $C, "\x04" |
171 | if $C; |
171 | if $C; |
172 | }; |
172 | }; |
173 | } |
173 | } |
174 | |
174 | |
175 | =item AnyEvent::Watchdog::on_exit { BLOCK; shift->() } |
175 | =item AnyEvent::Watchdog::Util::on_exit { BLOCK; shift->() } |
176 | |
176 | |
177 | Installs an exit hook that is executed when the program is about to exit, |
177 | Installs an exit hook that is executed when the program is about to exit, |
178 | while event processing is still active to some extent. |
178 | while event processing is still active to some extent. |
179 | |
179 | |
180 | The hook should do whatever it needs to do (close active connections, |
180 | The hook should do whatever it needs to do (close active connections, |