From: Jan Krüger Date: Wed, 24 Nov 2010 19:20:35 +0000 (+0100) Subject: jobd: use comma-separated values in --load-triggers X-Git-Url: https://repo.or.cz/w/girocco.git/commitdiff_plain/847171fa723773050fad53903bb358184e5224bb jobd: use comma-separated values in --load-triggers The previous attempt to use a two-value option required that bundling be turned off, which also affected the case sensitivity of options and made it impossible to use both -P for --progress and -p for --max-parallel. Therefore, use one argument for --load-triggers instead and just split it at commas. Signed-off-by: Jan Krüger --- diff --git a/jobd/jobd.pl b/jobd/jobd.pl index f41b7b2..98f5882 100755 --- a/jobd/jobd.pl +++ b/jobd/jobd.pl @@ -21,7 +21,7 @@ my $progress; my $kill_after = 900; my $max_par = 20; my $max_par_intensive = 1; -my @load_triggers = (10,2); +my $load_triggers = '10,2'; my $lockfile = "/tmp/jobd.lock"; my $restart_delay = 60; my $all_once; @@ -346,6 +346,7 @@ sub fatal($) { ######### Main {{{1 # Parse options +Getopt::Long::Configure('bundling'); my $parse_res = GetOptions( 'help|?' => sub { pod2usage(-verbose => 1, -exitval => 0); }, 'quiet|q' => \$quiet, @@ -353,7 +354,7 @@ my $parse_res = GetOptions( 'kill-after|k=i' => \$kill_after, 'max-parallel|p=i' => \$max_par, 'max-intensive-parallel|i=i' => \$max_par_intensive, - 'load-triggers=f{2}' => \@load_triggers, + 'load-triggers=s' => \$load_triggers, 'restart-delay|d=i' => \$restart_delay, 'lockfile|l=s' => \$lockfile, 'all-once|a' => \$all_once, @@ -367,8 +368,8 @@ unless ($quiet) { $progress = 1; } -@load_triggers = (0, 0) if (!-f '/proc/loadavg'); -($load_trig, $load_untrig) = @load_triggers; +$load_triggers = '0,0' if (!-f '/proc/loadavg'); +($load_trig, $load_untrig) = split(/,/, $load_triggers); if ($one) { queue_one($one); @@ -404,7 +405,7 @@ jobd [options] -p NUM | --max-parallel NUM how many jobs to run at the same time -i NUM | --max-intensive-parallel NUM how many resource-hungry jobs to run at the same time - --load-triggers TRIG UNTRIG stop queueing jobs at load above + --load-triggers TRIG,UNTRIG stop queueing jobs at load above TRIG and resume at load below UNTRIG -d NUM | --restart-delay SECONDS wait for this many seconds between queue runs @@ -443,7 +444,7 @@ Run no more than that many jobs at the same time. Run no more than that many resource-hungry jobs at the same time. Right now, this refers to repacking jobs. -=item B<--load-triggers TRIG UNTRIG> +=item B<--load-triggers TRIG,UNTRIG> If the first system load average (1 minute average) exceeds TRIG, don't queue any more jobs until it goes below UNTRIG. This is currently only supported on