… | |
… | |
9 | aemp command args... |
9 | aemp command args... |
10 | |
10 | |
11 | # protocol commands |
11 | # protocol commands |
12 | aemp snd <port> <arg...> # send a message |
12 | aemp snd <port> <arg...> # send a message |
13 | aemp mon <port> # wait till port is killed |
13 | aemp mon <port> # wait till port is killed |
14 | aemp rpc <port> <arg...> # send message, append reply |
14 | aemp cal <port> <arg...> # send message, append reply |
15 | aemp eval <node> <expr...> # evaluate expression |
15 | aemp eval <node> <expr...> # evaluate expression |
16 | aemp trace <node> # trace the network topology |
16 | aemp trace <node> # trace the network topology |
17 | |
17 | |
18 | # run a node |
18 | # run a node |
19 | aemp run configure_args... # run a node |
19 | aemp run configure_args... # run a node |
… | |
… | |
154 | Most useful to take advantage of some undocumented functionality inside |
154 | Most useful to take advantage of some undocumented functionality inside |
155 | nodes, such as node ports being able to call any method: |
155 | nodes, such as node ports being able to call any method: |
156 | |
156 | |
157 | aemp snd doomed AnyEvent::Watchdog::restart 1 |
157 | aemp snd doomed AnyEvent::Watchdog::restart 1 |
158 | |
158 | |
159 | =item rpc <port> <arg...> |
159 | =item cal <port> <arg...> |
160 | |
160 | |
161 | Like F<aemp snd>, but appends a local reply port to the message and waits |
161 | Like F<aemp cal>: appends a local reply port to the message and waits for |
162 | for a message to it. |
162 | a message to it. |
163 | |
163 | |
164 | Any return values will be JSON-encoded and printed separated by commas |
164 | Any return values will be JSON-encoded and printed separated by commas |
165 | (kind of like a JSON array without []-brackets). |
165 | (kind of like a JSON array without []-brackets). |
166 | |
166 | |
167 | Example: ask the (undocumented) time service of a node for it's current |
167 | Example: ask the (undocumented) time service of a node for its current |
168 | time. |
168 | time. |
169 | |
169 | |
170 | aemp rpc mynode time |
170 | aemp cal mynode time |
171 | |
171 | |
172 | =item mon <port> |
172 | =item mon <port> |
173 | |
173 | |
174 | Monitors the port and exits when it's monitorign callback is called. Most |
174 | Monitors the port and exits when it's monitorign callback is called. Most |
175 | useful to monitor node ports. |
175 | useful to monitor node ports. |
… | |
… | |
179 | aemp mon doomed |
179 | aemp mon doomed |
180 | |
180 | |
181 | =item eval <node> <expr...> |
181 | =item eval <node> <expr...> |
182 | |
182 | |
183 | Joins all remaining arguments into a string and evaluates it on the given |
183 | Joins all remaining arguments into a string and evaluates it on the given |
184 | node. Return values are handled as with F<aemp rpc>. |
184 | node. Return values are handled as with F<aemp cal>. |
185 | |
185 | |
186 | Example: find the unix process ID of the node called posicks. |
186 | Example: find the unix process ID of the node called posicks. |
187 | |
187 | |
188 | aemp eval posicks '$$' |
188 | aemp eval posicks '$$' |
189 | |
189 | |
… | |
… | |
581 | snd node_of $port, snd => $reply, "message sent successfully"; |
581 | snd node_of $port, snd => $reply, "message sent successfully"; |
582 | |
582 | |
583 | print join " ", $cv->recv, "\n"; |
583 | print join " ", $cv->recv, "\n"; |
584 | }, |
584 | }, |
585 | |
585 | |
586 | rpc => sub { |
586 | cal => sub { |
587 | my $port = shift @ARGV; |
587 | my $port = shift @ARGV; |
588 | init; |
588 | init; |
589 | |
589 | |
590 | my $cv = AE::cv; |
590 | my $cv = AE::cv; |
591 | my $to = AE::timer 5, 0, sub { exit 1 }; |
|
|
592 | snd $port, @ARGV, port { &$cv }; @ARGV = (); |
591 | cal $port, @ARGV, sub { &$cv }; @ARGV = (); |
593 | mon $port, $cv; |
|
|
594 | |
592 | |
595 | print +(substr JSON::XS->new->encode ([$cv->recv]), 1, -1), "\n"; |
593 | print +(substr JSON::XS->new->encode ([$cv->recv]), 1, -1), "\n"; |
596 | }, |
594 | }, |
597 | |
595 | |
598 | mon => sub { |
596 | mon => sub { |