From d8fb3c88a88c9089dc5997e61db93e712775548b Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Thu, 8 Feb 2018 12:37:23 -0800 Subject: [PATCH] jobd.pl: count multiple -q and/or -P options With multiple -q options explicitly set show_progress=0. With multiple -P options explicitly set show_progress=<-P count>. This provides the ability to request show_progress=0 or show_progress=2 behavior while running jobd.pl. Signed-off-by: Kyle J. McKay --- jobd/jobd.pl | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/jobd/jobd.pl b/jobd/jobd.pl index 32b0d73..edbea28 100755 --- a/jobd/jobd.pl +++ b/jobd/jobd.pl @@ -21,8 +21,8 @@ BEGIN {noFatalsToBrowser} use Girocco::ExecUtil; # Options -my $quiet; -my $progress; +my $quiet = 0; +my $progress = 0; my $cpus = online_cpus; my $kill_after = 900; my $max_par = $cpus ? $cpus * 2 : 8; @@ -553,8 +553,8 @@ my %one_once; my $parse_res = GetOptions( 'help|?|h' => sub { pod2usage(-verbose => 2, -exitval => 0, -input => $realpath0)}, - 'quiet|q' => \$quiet, - 'progress|P' => \$progress, + 'quiet|q' => sub {++$quiet}, + 'progress|P' => sub {++$progress}, 'kill-after|k=i' => \$kill_after, 'max-parallel|p=i' => \$max_par, 'max-intensive-parallel|i=i' => \$max_par_intensive, @@ -577,9 +577,12 @@ fatal("Error: can only use one out of --update-only, --gc-only and --needs-gc-on fatal("Error: --update-only, --gc-only or --needs-gc-only requires --all-once or --one") if $onlycnt && !($all_once || @one); -unless ($quiet) { - $ENV{'show_progress'} = '1'; - $progress = 1; +delete $ENV{'show_progress'}; +if ($quiet) { + $ENV{'show_progress'} = 0 if $quiet > 1; +} else { + $progress = 1 unless $progress; + $ENV{'show_progress'} = $progress; } $load_triggers = '0,0' unless defined((get_load_info())[0]); @@ -651,11 +654,13 @@ Print the full description of jobd.pl's options. =item B<--quiet> Suppress non-error messages, e.g. for use when running this task as a cronjob. +When given two or more times suppress update ref change lines in logs as well. =item B<--progress> Show information about the current status of the job queue occasionally. This -is automatically enabled if --quiet is not given. +is automatically enabled if --quiet is not given. When specified two or more +times full ref change details will be shown for updates. =item B<--kill-after SECONDS> -- 2.11.4.GIT