On Sun, 28 Apr 2013, Marc Lehmann wrote:

AnyEvent::Fork::Remote
(http://software.schmorp.de/pkg/AnyEvent-Fork-Remote)

Interesting implementation, can you shed some light on what

    # xored together must start and and with \n
    my $magic0 = "Pdk{6y[_zZ";
    my $magic1 = "Z^yZ7~i=oP";

does? :)

--
-- Mike

[email protected]



The remote is a bit of a misnomer, but thats the expected use case: create
a process remotely ("ssh somewhere perl") and then let it be managed by
AnyEvent::Fork::Remote.

While the module is not built on top of AnyEvent::Fork (it was supposed
to, but it didn't work out) and has a different API both in the "parent"
and in the "child", it is easy to make other modules work with either,
and in fact, AnyEvent::Fork::RPC and AnyEvent::Fork::Pool work with both
modules.

Here's a simple example that uses ssh to run perl on another box and
control it with AnyEvent::Fork::RPC:

  use AnyEvent;
  use AnyEvent::Fork::Remote;
  use AnyEvent::Fork::RPC;

  my $rpc = AnyEvent::Fork::Remote
     ->new_execp ("ssh", "ssh", "anotherbox", "perl")
     ->eval ('
          sub myrun {
             "this is process $$, and you passed <@_>"
          }
       ')
     ->AnyEvent::Fork::RPC::run ("myrun");

  my $cv = AE::cv;

  for (1..10) {
     $cv->begin;
     $rpc->($_, sub {
        print "remote function returned: $_[0]\n";
        $cv->end;
     });
  }

  $cv->recv;

If I ever find the time, I might add some AnyEvent::Fork::Remote::OpenSSH
module that uses openssh and port forwarding to implement the fork and
send_fh methods.

Hope it's useful as it is, it's still in an early stage of development.

Things that I vaguely plan to add is loading of local perl-only modules
(or just local files), to make it easier to use remote perls without
installing extra dependencies.



_______________________________________________
anyevent mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/anyevent

Reply via email to