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

Do a much earlier check for the mysql server being up and running and

return an XML error code (HTTP_SERVICE_UNAVAILABLE) which is an error
code we look for on the client side.
parent 3d8ee2ff
#!/usr/bin/perl -w
#
# Copyright (c) 2008-2018 University of Utah and the Flux Group.
# Copyright (c) 2008-2019 University of Utah and the Flux Group.
#
# {{{GENIPUBLIC-LICENSE
#
......@@ -247,6 +247,15 @@ sub Start($$)
my $starttime = [gettimeofday()];
#
# Check to see if we can connect to the DB. If not bail right away.
#
require emdbi;
if (!emdbi::DBExists("@TBDBNAME@")) {
return XMLError(HTTP_SERVICE_UNAVAILABLE(),
"CM temporarily offline; please try again later");
}
#
# Check for NoLogins; return XMLRPC
#
......
......@@ -61,6 +61,32 @@ BEGIN {
};
}
}
#
# Helper function to send back a properly formated XML error.
#
my $logging = 0;
my $logforked = 0;
my $logfile = undef;
sub XMLError($$)
{
my ($code, $string) = @_;
my $decoder = Frontier::RPC2->new();
$string = $decoder->encode_fault($code, $string);
# Make sure the error goes back to user not into the debug file.
if ($logging) {
LogEnd(0);
if (!$logforked) {
# Use eval to avoid messing up the output stream if any errors.
eval { $logfile->Store(); };
}
}
print "Content-Type: text/xml \n\n";
print $string;
exit(0);
}
#
# Turn off line buffering on output
......@@ -91,6 +117,14 @@ BEGIN {
exit(0);
}
}
#
# Check to see if we can connect to the DB. If not bail right away.
#
require emdbi;
if (!emdbi::DBExists("@TBDBNAME@")) {
XMLError(HTTP_SERVICE_UNAVAILABLE(),
"Server temporarily offline; please try again later");
}
}
use Data::Dumper;
......@@ -154,40 +188,13 @@ use Group;
my $debug = 0;
my $nostorelogs= 0;
my $noanything = 0;
# Flag for XMLERROR.
my $logging = 0;
my $logforked = 0;
my $logaborted = 0;
my $iserror = 0;
my $rpcerror = 0;
my $logfile = undef;
# Determined by version.
my $responder;
#
# Helper function to return a properly formated XML error.
#
sub XMLError($$)
{
my ($code, $string) = @_;
my $decoder = Frontier::RPC2->new();
$string = $decoder->encode_fault($code, $string);
# Make sure the error goes back to user not into the debug file.
if ($logging) {
LogEnd(0);
if (!$logforked) {
# Use eval to avoid messing up the output stream if any errors.
eval { $logfile->Store(); };
}
}
print "Content-Type: text/xml \n\n";
print $string;
exit(0);
}
#
# Check for NoLogins; return XMLRPC
#
......
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