From 7800172016bbdd62cac423b7df873a8677991910 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 27 Nov 2016 16:52:28 -0800 Subject: [PATCH] jobd/taskd: support --same-pid graceful restart option If jobd.pl or taskd.pl is run with the --same-pid option then when they are performing a requested graceful they will keep the same pid. Signed-off-by: Kyle J. McKay --- jobd/jobd.pl | 10 +++++++++- taskd/taskd.pl | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/jobd/jobd.pl b/jobd/jobd.pl index 75b112c..a49913c 100755 --- a/jobd/jobd.pl +++ b/jobd/jobd.pl @@ -31,6 +31,7 @@ my $load_triggers = $cpus ? sprintf("%g,%g", $cpus * 1.5, $cpus * 0.75) : "6,3"; my $lockfile = "/tmp/jobd-$Girocco::Config::tmpsuffix.lock"; my $restart_delay = 300; my $all_once; +my $same_pid; my $one; my ($load_trig, $load_untrig); @@ -519,6 +520,7 @@ my $parse_res = GetOptions( 'load-triggers=s' => \$load_triggers, 'restart-delay|d=i' => \$restart_delay, 'lockfile|l=s' => \$lockfile, + 'same-pid' => \$same_pid, 'all-once|a' => \$all_once, 'one|o=s' => \$one, ) || pod2usage(2); @@ -548,7 +550,7 @@ if ($all_once) { { if (run_perpetually() eq "restart") { error("Restarting in response to restart request... "); - $reexec->reexec; + $reexec->reexec($same_pid); error("Continuing after failed restart: $!"); chdir "/"; redo; @@ -581,6 +583,7 @@ jobd.pl [options] queue runs -l FILE | --lockfile FILE create a lockfile in the given location + --same-pid keep same pid during graceful restart -a | --all-once process the list only once -o PRJNAME | --one PRJNAME process only one project @@ -639,6 +642,11 @@ where $suffix is a 6-character string uniquely determined by the name and nicknme of this Girocco instance. The pid of the running jobd instance will be written to the lock file. +=item B<--same-pid> + +When performing a graceful restart, keep the same pid rather than switching to +a new one. + =item B<--all-once> Instead of perpetually processing all projects over and over again, process diff --git a/taskd/taskd.pl b/taskd/taskd.pl index b733549..406c5cf 100755 --- a/taskd/taskd.pl +++ b/taskd/taskd.pl @@ -81,6 +81,7 @@ my $inetd; my $idle_timeout; my $abbrev = 8; my $showff = 1; +my $same_pid; my $statusintv = 60; my $idleintv = 3600; my $maxspawn = 8; @@ -1139,6 +1140,7 @@ my $parse_res = GetOptions( 'abbrev=i' => \$abbrev, 'show-fast-forward-info' => \$showff, 'no-show-fast-forward-info' => sub {$showff = 0}, + 'same-pid' => \$same_pid, 'status-interval=i' => \$stiv, 'idle-status-interval=i' => \$idiv, ) || pod2usage(2); @@ -1333,7 +1335,7 @@ while (1) { } else { statmsg "RESTART: restart requested; now restarting"; statmsg "RESTART: restart requested; jobd restart scheduled in 5 seconds" if $restarter; - $reexec->reexec; + $reexec->reexec($same_pid); statmsg "RESTART: continuing after failed restart: $!"; chdir "/"; cancel_jobd_restart($restarter) if $restarter; @@ -1437,6 +1439,7 @@ taskd.pl [options] --abbrev=n abbreviate hashes to n (default is 8) --show-fast-forward-info show fast-forward info (default is on) --no-show-fast-forward-info disable showing fast-forward info + --same-pid keep same pid during graceful restart --status-interval=MINUTES status update interval (default 1) --idle-status-interval=IDLEMINUTES idle status interval (default 60) @@ -1528,6 +1531,11 @@ creation or deletion in order to determine whether or not it's a fast forward. Disable showing of fast-forward information for ref-change/ref-notify update messages. Instead just show a ' -> ' indicator. +=item B<--same-pid> + +When performing a graceful restart, keep the same pid rather than switching to +a new one. + =item B<--status-interval=MINUTES> If progress is enabled (with --progress or by default if no --inetd or --quiet) -- 2.11.4.GIT