AnyEvent-Beanstalk-Worker

 view release on metacpan or  search on metacpan

eg/ssh.pl  view on Meta::CPAN

    my $target  = shift;
    my $scripts = shift;

    my $results = shift;
    my $stdout  = shift;
    my $stderr  = shift;

    my $ipc = AnyEvent::Open3::Simple->new(
        on_start => sub {
            my $proc = shift;
            AE::log trace => "pid: " . $proc->pid;
        },

        on_stdout => sub {
            my $proc = shift;
            my $line = shift;
            AE::log trace => $proc->pid . " stdout: " . $line;
            $stdout->{$proc->pid} .= $line . "\n";
        },

        on_stderr => sub {
            my $proc = shift;
            my $line = shift;
            AE::log trace => $proc->pid . " stderr: " . $line;
            $stderr->{$proc->pid} .= $line . "\n";
        },

        on_exit => sub {
            my $proc  = shift;
            my $exval = shift;
            my $sig   = shift;

            AE::log trace => $proc->pid . " exit: $exval" if $exval;
            AE::log trace => $proc->pid . " signal: $sig" if $sig;
        },

        on_error => sub {
            my $err = shift;
            AE::log warn => $err;
            $cv_done->end;
        },

        on_success => sub {
            my $proc = shift;
            AE::log info => "success for " . $proc->pid;
            $results->{ $proc->pid } = 1;
            $cv_done->end;
        },

        on_fail => sub {
            my $proc = shift;
            AE::log error => "fail for " . $proc->pid;
            $results->{ $proc->pid } = 0;
            $cv_done->end;
        }
    );

    for my $scr (@$scripts) {
        $cv_done->begin;
        my ( $intr, $script ) = ( $scr->{interpreter}, $scr->{script} );
        $ipc->run( "ssh", "-o", "ConnectTimeout=3", $target, $intr, \$script );
    }
}

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.586 second using v1.00-cache-2.02-grep-82fe00e-cpan-cec75d87357c )