add a check for db connection to handle the db going away and coming back

This commit is contained in:
Isaac Connor 2014-10-15 09:43:00 -04:00
parent 7dbad45e30
commit 9eb88d3f15
1 changed files with 14 additions and 3 deletions

View File

@ -111,8 +111,19 @@ my $swap_image_path = $Config{ZM_PATH_SWAP};
my $loop = 1;
my $cleaned = 0;
MAIN: while( $loop )
{
MAIN: while( $loop ) {
while ( ! ( $dbh and $dbh->ping() ) ) {
$dbh = zmDbConnect();
last if $dbh;
if ( $continuous ) {
# if we are running continuously, then just skip to the next interval, otherwise we are a one off run, so wait a second and retry until someone kills us.
sleep( $Config{ZM_AUDIT_CHECK_INTERVAL} );
} else {
sleep 1;
} # end if
} # end while can't connect to the db
my $db_monitors;
my $monitorSelectSql = "select Id from Monitors order by Id";
my $monitorSelectSth = $dbh->prepare_cached( $monitorSelectSql ) or Fatal( "Can't prepare '$monitorSelectSql': ".$dbh->errstr() );