From c63a9f91248b1b00ec2223805d83da1e1d37945d Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Tue, 12 Oct 2010 03:46:08 -0400 Subject: [PATCH] allow clean re-exec for smoother upgrades (closes MS #2532) --- Changelog | 4 ++++ Crypt/Monkeysphere/MSVA.pm | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index d885931..b4add1a 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,10 @@ msva-perl (0.5~pre) unstable; urgency=low * Conditionally rely on Gtk2 perl module -- no marginal UI without it, but you can also install the MSVA now without needing to pull in a bunch of Gtk libs (closes MS #2514) + * Sending a SIGHUP to the running server now re-execs it cleanly, + keeping the same port assignments and monitoring the same child + process. This can be used to upgrade running msva instances after a + package update (closes MS #2532) -- Daniel Kahn Gillmor Mon, 11 Oct 2010 16:02:22 -0400 diff --git a/Crypt/Monkeysphere/MSVA.pm b/Crypt/Monkeysphere/MSVA.pm index e620a4c..d4c5852 100755 --- a/Crypt/Monkeysphere/MSVA.pm +++ b/Crypt/Monkeysphere/MSVA.pm @@ -666,8 +666,11 @@ } $self->port($port); - my $argcount = @ARGV; - if ($argcount) { + if ((exists $ENV{MSVA_CHILD_PID}) && ($ENV{MSVA_CHILD_PID} ne '')) { + # this is most likely a re-exec. + msvalog('info', "This appears to be a re-exec, monitoring child pid %d\n", $ENV{MSVA_CHILD_PID}); + $self->{child_pid} = $ENV{MSVA_CHILD_PID} + 0; + } elsif ($#ARGV >= 0) { $self->{child_pid} = 0; # indicate that we are planning to fork. my $fork = fork(); if (! defined $fork) { @@ -676,6 +679,7 @@ if ($fork) { msvalog('debug', "Child process has PID %d\n", $fork); $self->{child_pid} = $fork; + $ENV{MSVA_CHILD_PID} = $fork; } else { msvalog('verbose', "PID %d executing: \n", $$); for my $arg (@ARGV) { -- 2.26.2