ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/bin/aemp
(Generate patch)

Comparing AnyEvent-MP/bin/aemp (file contents):
Revision 1.41 by root, Fri Sep 11 02:32:23 2009 UTC vs.
Revision 1.42 by root, Sat Sep 12 04:46:21 2009 UTC

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 cal <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 shell [<node>] # run an interactive shell
16 aemp trace <node> # trace the network topology 17 aemp trace <node> # trace the network topology
17 18
18 # run a node 19 # run a node
19 aemp run configure_args... # run a node 20 aemp run configure_args... # run a node
20 aemp restart <node> # restart a node if running under watchdog 21 aemp restart <node> # restart a node if running under watchdog
546 snd $reply, seed => $node; 547 snd $reply, seed => $node;
547 548
548 $cv->recv; 549 $cv->recv;
549} 550}
550 551
552sub shell {
553 init;
554
555 my $node = shift @ARGV || $NODE;
556 $| = 1;
557
558 print <<EOF;
559Entering interactive shell - no commandline editing of course (use rlfe etc.).
560
561= display a list of nodes
562=name switch to another node
563
564EOF
565 print "$node> ";
566 my $cv = AE::cv;
567 my $t = AE::io *STDIN, 0, sub {
568 chomp (my $line = <STDIN>);
569
570 if ($line =~ s/^=//) {
571 if (length $line) {
572 $node = $line;
573 } else {
574 print +(join " ", AnyEvent::MP::Kernel::up_nodes), "\n";
575 }
576 } else {
577 my $time = AE::time;
578 AnyEvent::MP::Kernel::eval_on $node, $line, port {
579 my ($err, @res) = @_;
580
581 $time = AE::time - $time;
582
583 print "\n $node: $line\n";
584 if (length $err) {
585 print " $err @res";
586 } else {
587 print " ", JSON::XS::encode_json \@_;
588 }
589 printf "\n %0.3fs\n", $time;
590 print "$node> ";
591 };
592 }
593
594 print "$node> ";
595 };
596 $cv->recv;
597}
598
551sub node_eval { 599sub node_eval {
552 my ($node, $expr) = @_; 600 my ($node, $expr) = @_;
553 601
554 init; 602 init;
555 603
604 eval => sub { 652 eval => sub {
605 my $node = node_of shift @ARGV; 653 my $node = node_of shift @ARGV;
606 my $expr = join " ", @ARGV; @ARGV = (); 654 my $expr = join " ", @ARGV; @ARGV = ();
607 node_eval $node, $expr; 655 node_eval $node, $expr;
608 }, 656 },
657
658 shell => \&shell,
609 659
610 trace => sub { 660 trace => sub {
611 @ARGV >= 1 661 @ARGV >= 1
612 or die "node id missing\n"; 662 or die "node id missing\n";
613 663

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines