… | |
… | |
57 | |
57 | |
58 | =cut |
58 | =cut |
59 | |
59 | |
60 | use common::sense; |
60 | use common::sense; |
61 | |
61 | |
|
|
62 | # must come before anything else |
62 | BEGIN { |
63 | BEGIN { |
63 | if ($ARGV[0] eq "run") { |
64 | if ($ARGV[0] eq "run") { |
64 | shift; |
65 | shift; |
65 | |
66 | |
66 | # d'oh |
67 | # d'oh |
67 | eval "use AnyEvent::Watchdog qw(autorestart heartbeat=300)"; |
68 | require AnyEvent::Watchdog; |
|
|
69 | AnyEvent::Watchdog::autorestart (1); |
|
|
70 | AnyEvent::Watchdog::heartbeat (300); |
68 | |
71 | |
69 | require AnyEvent; |
72 | require AnyEvent; |
70 | require AnyEvent::MP; |
73 | require AnyEvent::MP; |
71 | AnyEvent::MP::initialise_node (@ARGV); |
74 | AnyEvent::MP::initialise_node (@ARGV); |
72 | |
75 | |
… | |
… | |
164 | |
167 | |
165 | my $cv = AE::cv; |
168 | my $cv = AE::cv; |
166 | my $to = AE::timer 5, 0, sub { $cv->("timeout") }; |
169 | my $to = AE::timer 5, 0, sub { $cv->("timeout") }; |
167 | mon $port, $cv; |
170 | mon $port, $cv; |
168 | my $reply = port { &$cv; 1 }; |
171 | my $reply = port { &$cv; 1 }; |
169 | snd node_of $port, relay => $reply, "ok"; |
172 | snd node_of $port, snd => $reply, "ok"; |
170 | |
173 | |
171 | print join " ", $cv->recv, "\n"; |
174 | print join " ", $cv->recv, "\n"; |
172 | }, |
175 | }, |
173 | |
176 | |
174 | rpc => sub { |
177 | rpc => sub { |