Commit 9eca8564 authored by Leigh Stoller's avatar Leigh Stoller

Left this out of previous commit.

parent e4262649
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2008-2016 University of Utah and the Flux Group. # Copyright (c) 2008-2017 University of Utah and the Flux Group.
# #
# {{{GENIPUBLIC-LICENSE # {{{GENIPUBLIC-LICENSE
# #
...@@ -130,73 +130,6 @@ sub handler() ...@@ -130,73 +130,6 @@ sub handler()
$SIG{HUP} = \&handler $SIG{HUP} = \&handler
if (! ($debug || $oneshot)); if (! ($debug || $oneshot));
#
# We call this function on each instance.
#
sub CheckInstanceStatus($)
{
my ($uuid) = @_;
my $instance = APT_Instance->Lookup($uuid);
if (!defined($instance)) {
print STDERR "$instance no longer exists\n";
return 0;
}
$instance->Flush();
my $slice = $instance->GetGeniSlice();
if (!defined($slice)) {
print STDERR "No slice for instance $uuid\n";
return 0;
}
$slice->Flush();
# Do not bother if the slice is locked, try again next interval.
if (defined($slice->locked())) {
print STDERR "Slice is locked for instance $uuid\n";
return 0;
}
print STDERR "Checking instance " . $instance->name() . "\n"
if ($debug);
# Use debug option to keep it from going into the background.
my $output = emutil::ExecQuiet("$SUDO -u $PROTOUSER ".
"$MANAGEINSTANCE -d refresh $uuid");
# We do not care about failure here.
if ($?) {
print STDERR "Failure for instance " . $instance->name() . ":\n" .
$output . "\n";
}
print STDERR "Done checking instance " . $instance->name() . "\n"
if ($debug);
return 0;
}
#
# Check status for all instances.
#
sub CheckAllInstances()
{
my @return_codes = ();
my @instances = ();
my $query_result =
DBQueryWarn("select uuid from apt_instances " .
"where status='ready' and ".
" (UNIX_TIMESTAMP(now()) - ".
" UNIX_TIMESTAMP(created) > 300)");
return
if (!$query_result || !$query_result->numrows);
while (my ($uuid) = $query_result->fetchrow_array()) {
push(@instances, $uuid);
}
if (ParRun({"maxwaittime" => 1000,
"maxchildren" => 10},
\@return_codes, \&CheckInstanceStatus, @instances)) {
return;
}
}
# #
# Loop, asking for status for every instance. # Loop, asking for status for every instance.
# #
...@@ -208,8 +141,6 @@ while (1) { ...@@ -208,8 +141,6 @@ while (1) {
print "Running at ". print "Running at ".
POSIX::strftime("20%y-%m-%d %H:%M:%S", localtime()) . "\n"; POSIX::strftime("20%y-%m-%d %H:%M:%S", localtime()) . "\n";
CheckAllInstances();
exit(0) exit(0)
if ($oneshot); if ($oneshot);
......
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