Mojo::Run - asynchronous external command execution for Mojo
version 0.3
use Mojo::Run; use Mojo::Log; my $run = Mojo::Run->new; $run->max_forks(10); $run->log(Mojo::Log->new( level => 'error', path => 'log/mojo_run.log', )); $run->spawn( cmd => sub { my $pid = shift; my $param = shift; # {a => 1, b => 2} my $data = {}; ... do something return $data; }, param => {a => 1, b => 2}, exec_timeout => 120, # sec stdout_cb => sub { my ($pid, $chunk) = @_; }, stderr_cb => sub { my ($pid, $chunk) = @_; }, exit_cb => sub { my $pid = shift; my $res = shift; warn $res->{result}->[0]; }, ); $run->spawn( cmd => 'ps aux', exit_cb => sub { my $pid = shift; my $res = shift; }, ); $run->spawn( cmd => ['perl', '-v'], exit_cb => sub { my $pid = shift; my $res = shift; }, ); $run->start;
Result in exit_cb is a HASH with following keys:
https://github.com/likhatskiy/Mojo-Run
Alexey Likhatskiy, <likhatskiy@gmail.com>
Copyright (C) 2012-2013 "Alexey Likhatskiy"
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Mojo::Run, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::Run
CPAN shell
perl -MCPAN -e shell install Mojo::Run
For more information on module installation, please visit the detailed CPAN module installation guide.