announcement: AnyEvent::Fork::Remote

Marc Lehmann schmorp at schmorp.de
Sun Apr 28 17:58:44 CEST 2013


Just wanted to announce the fourth installment in the AnyEvent::Fork, uhm,
trilogy, namely:

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

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.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list