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

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

parent 14ff7af4
......@@ -588,8 +588,8 @@ sub HUPDaemon($) {
#
# Restart a daemon if running. Do not start if not running.
#
sub RestartDaemon($) {
my ($name) = @_;
sub RestartDaemon($;$) {
my ($name, $path) = @_;
my $pidfile = "$VARRUN/${name}.pid";
......@@ -605,7 +605,9 @@ sub RestartDaemon($) {
}
SignalDaemon($name, 'TERM');
sleep(1);
if (ExecQuiet("$TBROOT/sbin/$name")) {
$path = "$TBROOT/sbin/$name"
if (!defined($path));
if (ExecQuiet($path) == 0) {
PhaseSucceed("$name started");
}
PhaseFail("Could not start $name");
......
......@@ -7,6 +7,7 @@
use strict;
use English;
use Getopt::Std;
use Data::Dumper;
#
# Update DB.
......@@ -57,17 +58,22 @@ BEGIN
{
eval "require emdbi";
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 libtestbed;
use libinstall;
# Need this below.
my $objdir = `/bin/pwd`;
chomp($objdir);
#
# Parse command arguments.
#
......
......@@ -64,11 +64,13 @@ $| = 1;
BEGIN
{
if (-e "../Makeconf") {
my $objdir = `/bin/pwd`;
chomp($objdir);
# 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");
unshift(@INC, "$objdir/../db");
unshift(@INC, "$objdir/@top_srcdir@/install");
unshift(@INC, "$objdir/@top_srcdir@/tbsetup");
unshift(@INC, "$objdir/../tbsetup");
}
}
use emdb;
......@@ -112,8 +114,16 @@ if (! (-e "../db/dbupdate" && -e "./update-install")) {
Fatal("Cannot find dbupdate script! Running from the object dir?");
}
my @INCDIRS = ("-I.", "-I../tbsetup", "-I../db",
"-I${SRCDIR}/tbsetup", "-I${SRCDIR}/install");
my $objdir = `/bin/pwd`;
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.
......
......@@ -42,10 +42,12 @@ sub InstallUpdate($$)
if (! -e "$VARRUN/stated.pid") {
PhaseSkip("Testbed not running");
}
if (ExecQuiet("$TBROOT/sbin/checknodes_daemon")) {
PhaseSucceed("checknodes_daemon started");
# Old version of daemon still running.
if (-e "$VARRUN/checknodes.pid" &&
ExecQuiet("pgrep -f checknodes_daemon")) {
SignalDaemon("checknodes", "TERM");
}
PhaseFail("Could not start checknodes_daemon");
RestartDaemon("checknodes_daemon");
};
}
return 0;
......
......@@ -51,19 +51,46 @@ sub InstallUpdate($$)
if ($phase eq "post") {
Phase "daemons", "Restarting daemons", 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");
};
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");
};
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");
};
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 {
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");
};
......
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