Commit 1cea01c5 authored by Leigh B Stoller's avatar Leigh B Stoller

More tweaks and fixes. This is harder then I thought.

parent 14ff7af4
...@@ -588,8 +588,8 @@ sub HUPDaemon($) { ...@@ -588,8 +588,8 @@ sub HUPDaemon($) {
# #
# Restart a daemon if running. Do not start if not running. # Restart a daemon if running. Do not start if not running.
# #
sub RestartDaemon($) { sub RestartDaemon($;$) {
my ($name) = @_; my ($name, $path) = @_;
my $pidfile = "$VARRUN/${name}.pid"; my $pidfile = "$VARRUN/${name}.pid";
...@@ -605,7 +605,9 @@ sub RestartDaemon($) { ...@@ -605,7 +605,9 @@ sub RestartDaemon($) {
} }
SignalDaemon($name, 'TERM'); SignalDaemon($name, 'TERM');
sleep(1); sleep(1);
if (ExecQuiet("$TBROOT/sbin/$name")) { $path = "$TBROOT/sbin/$name"
if (!defined($path));
if (ExecQuiet($path) == 0) {
PhaseSucceed("$name started"); PhaseSucceed("$name started");
} }
PhaseFail("Could not start $name"); PhaseFail("Could not start $name");
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
use strict; use strict;
use English; use English;
use Getopt::Std; use Getopt::Std;
use Data::Dumper;
# #
# Update DB. # Update DB.
...@@ -57,17 +58,22 @@ BEGIN ...@@ -57,17 +58,22 @@ BEGIN
{ {
eval "require emdbi"; eval "require emdbi";
if ($@) { if ($@) {
unshift(@INC, "@prefix@/lib"); if (-e "../Makeconf") {
# Prior to first install or running from object dir.
unshift(@INC, "../db");
unshift(@INC, "@top_srcdir@/install");
unshift(@INC, "@top_srcdir@/tbsetup");
unshift(@INC, "../tbsetup");
}
else {
unshift(@INC, "@prefix@/lib");
}
} }
} }
use emdb; use emdb;
use libtestbed; use libtestbed;
use libinstall; use libinstall;
# Need this below.
my $objdir = `/bin/pwd`;
chomp($objdir);
# #
# Parse command arguments. # Parse command arguments.
# #
......
...@@ -64,11 +64,13 @@ $| = 1; ...@@ -64,11 +64,13 @@ $| = 1;
BEGIN BEGIN
{ {
if (-e "../Makeconf") { if (-e "../Makeconf") {
my $objdir = `/bin/pwd`;
chomp($objdir);
# Prior to first install or running from object dir. # Prior to first install or running from object dir.
unshift(@INC, "../db"); unshift(@INC, "$objdir/../db");
unshift(@INC, "@top_srcdir@/install"); unshift(@INC, "$objdir/@top_srcdir@/install");
unshift(@INC, "@top_srcdir@/tbsetup"); unshift(@INC, "$objdir/@top_srcdir@/tbsetup");
unshift(@INC, "../tbsetup"); unshift(@INC, "$objdir/../tbsetup");
} }
} }
use emdb; use emdb;
...@@ -112,8 +114,16 @@ if (! (-e "../db/dbupdate" && -e "./update-install")) { ...@@ -112,8 +114,16 @@ if (! (-e "../db/dbupdate" && -e "./update-install")) {
Fatal("Cannot find dbupdate script! Running from the object dir?"); Fatal("Cannot find dbupdate script! Running from the object dir?");
} }
my @INCDIRS = ("-I.", "-I../tbsetup", "-I../db", my $objdir = `/bin/pwd`;
"-I${SRCDIR}/tbsetup", "-I${SRCDIR}/install"); chomp($objdir);
my @INCDIRS = ("-I${objdir}", "-I${objdir}/../tbsetup",
"-I${objdir}/../db",
"-I${objdir}/${SRCDIR}/tbsetup",
"-I${objdir}/${SRCDIR}/install",
# To catch a few extra things that do not normally change.
"-I@prefix@/lib"
);
# #
# Dump the testbed version numbers in all modes. # Dump the testbed version numbers in all modes.
......
...@@ -42,10 +42,12 @@ sub InstallUpdate($$) ...@@ -42,10 +42,12 @@ sub InstallUpdate($$)
if (! -e "$VARRUN/stated.pid") { if (! -e "$VARRUN/stated.pid") {
PhaseSkip("Testbed not running"); PhaseSkip("Testbed not running");
} }
if (ExecQuiet("$TBROOT/sbin/checknodes_daemon")) { # Old version of daemon still running.
PhaseSucceed("checknodes_daemon started"); if (-e "$VARRUN/checknodes.pid" &&
ExecQuiet("pgrep -f checknodes_daemon")) {
SignalDaemon("checknodes", "TERM");
} }
PhaseFail("Could not start checknodes_daemon"); RestartDaemon("checknodes_daemon");
}; };
} }
return 0; return 0;
......
...@@ -51,19 +51,46 @@ sub InstallUpdate($$) ...@@ -51,19 +51,46 @@ sub InstallUpdate($$)
if ($phase eq "post") { if ($phase eq "post") {
Phase "daemons", "Restarting daemons", sub { Phase "daemons", "Restarting daemons", sub {
Phase "reload_daemon", "Restarting reload_daemon", sub { Phase "reload_daemon", "Restarting reload_daemon", sub {
# Old version of daemon still running.
if (! -e "$VARRUN/reload_daemon.pid" &&
!ExecQuiet("pgrep -f reload_daemon")) {
ExecQuietFatal("pkill -f reload_daemon");
}
RestartDaemon("reload_daemon"); RestartDaemon("reload_daemon");
}; };
Phase "checkup_daemon", "Restarting checkup_daemon", sub { Phase "checkup_daemon", "Restarting checkup_daemon", sub {
# Old version of daemon still running.
if (! -e "$VARRUN/checkup_daemon.pid" &&
!ExecQuiet("pgrep -f checkup_daemon")) {
ExecQuietFatal("pkill -f checkup_daemon");
}
RestartDaemon("checkup_daemon"); RestartDaemon("checkup_daemon");
}; };
Phase "pool_daemon", "Restarting pool_daemon", sub { Phase "pool_daemon", "Restarting pool_daemon", sub {
# Old version of daemon still running.
if (! -e "$VARRUN/pool_daemon.pid" &&
!ExecQuiet("pgrep -f pool_daemon")) {
ExecQuietFatal("pkill -f pool_daemon");
}
RestartDaemon("pool_daemon"); RestartDaemon("pool_daemon");
}; };
Phase "expire_daemon", "Restarting expire_daemon", sub { Phase "expire_daemon", "Restarting expire_daemon", sub {
RestartDaemon("expire_daemon"); # Old version of daemon still running.
if (! -e "$VARRUN/expire_daemon.pid" &&
!ExecQuiet("pgrep -f expire_daemon")) {
ExecQuietFatal("pkill -f expire_daemon");
}
RestartDaemon("expire_daemon",
"$TBROOT/sbin/protogeni/expire_daemon");
}; };
Phase "sa_daemon", "Restarting sa_daemon", sub { Phase "sa_daemon", "Restarting sa_daemon", sub {
RestartDaemon("sa_daemon"); # Old version of daemon still running.
if (! -e "$VARRUN/sa_daemon.pid" &&
!ExecQuiet("pgrep -f sa_daemon")) {
ExecQuietFatal("pkill -f sa_daemon");
}
RestartDaemon("sa_daemon",
"$TBROOT/sbin/protogeni/sa_daemon");
}; };
PhaseSucceed("Daemons Restarted"); PhaseSucceed("Daemons Restarted");
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment