Commit e35c367e authored by Leigh Stoller's avatar Leigh Stoller

Stop Frisbee daemons when shutting down the testbed.

parent c161fc3a
......@@ -137,6 +137,30 @@ sub updated($) { return field($_[0], "updated"); }
sub mbr_version($) { return field($_[0], "mbr_version"); }
sub access_key($) { return field($_[0], "access_key"); }
#
# Get a list of all running frisbee images.
#
sub ActiveImages($)
{
my ($class) = @_;
my @result = ();
my $query_result =
DBQueryWarn("select imageid from images where frisbee_pid!=0");
return undef
if (!defined($query_result));
while (my ($imageid) = $query_result->fetchrow_array()) {
my $image = Image->Lookup($imageid);
if (!defined($image)) {
print STDERR "*** Could not find DB object for image $imageid\n";
return undef;
}
push(@result, $image);
}
return \@result;
}
#
# Refresh a class instance by reloading from the DB.
#
......
......@@ -45,6 +45,7 @@ my $PGENISUPPORT = @PROTOGENI_SUPPORT@;
my $INSTALLUPDATE= "$TB/sbin/update-install";
my $SETSITEVAR = "$TB/sbin/setsitevar";
my $STARTUP = "/usr/local/etc/rc.d/3.testbed.sh";
my $FRISBEE = "$TB/sbin/frisbeelauncher";
my $tempfile = "/var/tmp/update.$$";
# Protos
......@@ -85,6 +86,7 @@ BEGIN
use emdb;
use libEmulab;
use libtestbed;
use Image;
#
# Parse command arguments.
......@@ -305,6 +307,23 @@ if ($stopbed) {
Fatal("Could not stop testbed daemons. Stopping.");
}
$stopped = 1;
my $activeimages = Image->ActiveImages();
if (defined($activeimages)) {
my @activeimages = @{ $activeimages };
if (@activeimages) {
print "** Stopping running frisbee processes ...\n";
}
foreach my $image (@activeimages) {
my $imageid = $image->imageid();
print "-> Killing frisbee for $image ...\n";
system("$FRISBEE -k $imageid");
if ($?) {
Fatal("Could not stop frisbee for $image!");
}
}
}
print "** Testbed is stopped. Proceeding to update\n";
#
......
......@@ -28,6 +28,7 @@ my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $SETSITEVAR = "$TB/sbin/setsitevar";
my $STARTUP = "/usr/local/etc/rc.d/3.testbed.sh";
my $FRISBEE = "$TB/sbin/frisbeelauncher";
# Protos
sub Fatal($);
......@@ -45,6 +46,7 @@ use lib "@prefix@/lib";
use libdb;
use libtestbed;
use libEmulab;
use Image;
#
# Parse command arguments.
......@@ -161,6 +163,21 @@ system("$STARTUP stop >/dev/null 2>&1");
if ($?) {
Fatal("Could not stop testbed daemons. Stopping. Best to reboot!");
}
my $activeimages = Image->ActiveImages();
if (defined($activeimages)) {
my @activeimages = @{ $activeimages };
if (@activeimages) {
print "** Stopping running frisbee processes ...\n";
}
foreach my $image (@activeimages) {
my $imageid = $image->imageid();
print "-> Killing frisbee for $image ...\n";
system("$FRISBEE -k $imageid");
if ($?) {
Fatal("Could not stop frisbee for $image!");
}
}
}
print "** Testbed is stopped. Safe to power off or reboot\n";
exit(0);
......
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