Skip to content

Commit

Permalink
make max processes a optional parameter, defaults to 2
Browse files Browse the repository at this point in the history
  • Loading branch information
sajp committed Oct 17, 2012
1 parent 72023c1 commit 66f48a0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/LIMS2/Task/General/CacheReports.pm
Expand Up @@ -19,13 +19,20 @@ use IPC::System::Simple qw( system );

extends 'LIMS2::Task';

has max_processes => (
is => 'ro',
isa => 'Int',
default => 2,
traits => [ 'Getopt' ],
cmd_flag => 'max-processes'
);

override abstract => sub {
'Pre Cache reports for webapp';
};

const my $LIMS2_REPORT_CACHE_CONFIG => $ENV{LIMS2_REPORT_CACHE_CONFIG};
const my $LIMS2_REPORT_DIR => $ENV{LIMS2_REPORT_DIR};
const my $MAX_PROCESSES => 3;

sub execute {
my ( $self, $opts, $args ) = @_;
Expand All @@ -39,7 +46,7 @@ sub execute {
$self->log->info( "Loading data from $LIMS2_REPORT_CACHE_CONFIG" );
my $it = iyaml( $LIMS2_REPORT_CACHE_CONFIG );

my $pm = Parallel::ForkManager->new( $MAX_PROCESSES );
my $pm = Parallel::ForkManager->new( $self->max_processes );

$pm->run_on_start(
sub {
Expand Down

0 comments on commit 66f48a0

Please sign in to comment.