add db reconnects to zmwatch.

This commit is contained in:
Isaac Connor 2018-09-07 16:29:23 -04:00
parent af32d59aa1
commit 426aeea95b
1 changed files with 12 additions and 6 deletions

View File

@ -78,6 +78,11 @@ my $sth = $dbh->prepare_cached($sql)
or Fatal("Can't prepare '$sql': ".$dbh->errstr());
while( 1 ) {
while ( ! ( $dbh and $dbh->ping() ) ) {
if ( ! ( $dbh = zmDbConnect() ) ) {
sleep($Config{ZM_WATCH_CHECK_INTERVAL});
}
}
my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () )
or Fatal('Can\'t execute: '.$sth->errstr());
@ -98,7 +103,7 @@ while( 1 ) {
Debug("Monitor $$monitor{Id} LastWriteTime is $capture_time.");
if ( !$capture_time ) {
my $startup_time = zmGetStartupTime($monitor);
if ( $now - $startup_time > $Config{ZM_WATCH_MAX_DELAY} ) {
if ( ( $now - $startup_time ) > $Config{ZM_WATCH_MAX_DELAY} ) {
Info(
"Restarting capture daemon for $$monitor{Name}, no image since startup. ".
"Startup time was $startup_time - now $now > $Config{ZM_WATCH_MAX_DELAY}"
@ -111,7 +116,8 @@ while( 1 ) {
}
}
if ( ! $restart ) {
my $max_image_delay = ( $monitor->{MaxFPS}
my $max_image_delay = (
$monitor->{MaxFPS}
&&($monitor->{MaxFPS}>0)
&&($monitor->{MaxFPS}<1)
) ? (3/$monitor->{MaxFPS})