-
-
05 May 2010 00:19:49 UTC
- Distribution: App-CLI-Plugin-Parallel-ForkManager
- Module version: 1.01
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (2)
- Testers (151 / 0 / 0)
- Kwalitee
Bus factor: 1- License: perl_5
- Activity
24 month- Tools
- Download (23.47KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 1 contributors- Akira Horimoto
- Dependencies
- App::CLI::Extension
- Parallel::ForkManager
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
App::CLI::Plugin::Parallel::ForkManager - for App::CLI::Extension fork plugin module
VERSION
1.01
SYNOPSIS
# MyApp.pm package MyApp; use strict; use base qw(App::CLI::Extension); # extension method __PACKAGE__->load_plugins(qw(Parallel::ForkManager)); # extension method __PACKAGE__->config( parallel_fork_manager => 5 ); 1; # MyApp/Fork.pm package MyApp::Fork; use strict; use base qw(App::CLI::Command); use LWP::UserAgent; use HTTP::Request; our %LINKS = (cpan => "http://search.cpan.org", perl => "http://www.perl.org", foo => "http://foo.foo/"); sub options { return ("maxprocs=i" => "maxprocs") }; sub run { my($self, @argv) = @_; $self->pm->run_on_start(sub { my ($pid, $ident) = @_; print "$ident PID[$pid] start\n"; }); $self->pm->run_on_finish(sub { my ($pid, $exit_value, $ident) = @_; print "$ident PID[$pid] finish. exit_value: $exit_value\n"; }); foreach my $key (keys %LINKS) { my $pid = $self->pm->start($key) and next; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => $LINKS{$key}); my $res = $ua->request($req); if ($res->is_success) { printf "%s's status code: %d\n", $key, $res->code; } else { printf "ERROR: $key %s\n", $res->status_line; } $self->pm->finish; } $self->pm->wait_all_children; } 1; # myapp #!/usr/bin/perl use strict; use MyApp; MyApp->dispatch; # execute [kurt@localhost ~] ./myapp fork perl PID[3193] start cpan PID[3194] start foo PID[3195] start perl's status code: 200 perl PID[3193] finish. exit_value: 0 cpan's status code: 200 cpan PID[3194] finish. exit_value: 0 foo's status code: 200 cpan PID[3195] finish. exit_value: 0
DESCRIPTION
App::CLI::Plugin::Parallel::ForkManager - Parallel::ForkManager plugin module
pm method setting
__PACKAGE__->config( parallel_fork_manager => $maxprocs );
or if --maxprocs option is defined. it applies.
# in MyApp/**.pm sub options { return ( "maxprocs=i" => "maxprocs" ) ; } # execute [kurt@localhost ~] ./myapp fork --maxprocs=10
METHOD
pm
return Parallel::ForkManager object.
AUTHOR
Akira Horimoto
SEE ALSO
App::CLI::Extension Parallel::ForkManager
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
COPYRIGHT
Copyright (C) 2010 Akira Horimoto
Module Install Instructions
To install App::CLI::Plugin::Parallel::ForkManager, copy and paste the appropriate command in to your terminal.
cpanm App::CLI::Plugin::Parallel::ForkManager
perl -MCPAN -e shell install App::CLI::Plugin::Parallel::ForkManager
For more information on module installation, please visit the detailed CPAN module installation guide.