add db reconnects to zmwatch.
This commit is contained in:
parent
af32d59aa1
commit
426aeea95b
|
@ -78,6 +78,11 @@ my $sth = $dbh->prepare_cached($sql)
|
||||||
or Fatal("Can't prepare '$sql': ".$dbh->errstr());
|
or Fatal("Can't prepare '$sql': ".$dbh->errstr());
|
||||||
|
|
||||||
while( 1 ) {
|
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} : () )
|
my $res = $sth->execute( $Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID} : () )
|
||||||
or Fatal('Can\'t execute: '.$sth->errstr());
|
or Fatal('Can\'t execute: '.$sth->errstr());
|
||||||
|
@ -98,7 +103,7 @@ while( 1 ) {
|
||||||
Debug("Monitor $$monitor{Id} LastWriteTime is $capture_time.");
|
Debug("Monitor $$monitor{Id} LastWriteTime is $capture_time.");
|
||||||
if ( !$capture_time ) {
|
if ( !$capture_time ) {
|
||||||
my $startup_time = zmGetStartupTime($monitor);
|
my $startup_time = zmGetStartupTime($monitor);
|
||||||
if ( $now - $startup_time > $Config{ZM_WATCH_MAX_DELAY} ) {
|
if ( ( $now - $startup_time ) > $Config{ZM_WATCH_MAX_DELAY} ) {
|
||||||
Info(
|
Info(
|
||||||
"Restarting capture daemon for $$monitor{Name}, no image since startup. ".
|
"Restarting capture daemon for $$monitor{Name}, no image since startup. ".
|
||||||
"Startup time was $startup_time - now $now > $Config{ZM_WATCH_MAX_DELAY}"
|
"Startup time was $startup_time - now $now > $Config{ZM_WATCH_MAX_DELAY}"
|
||||||
|
@ -111,11 +116,12 @@ while( 1 ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ! $restart ) {
|
if ( ! $restart ) {
|
||||||
my $max_image_delay = ( $monitor->{MaxFPS}
|
my $max_image_delay = (
|
||||||
&&($monitor->{MaxFPS}>0)
|
$monitor->{MaxFPS}
|
||||||
&&($monitor->{MaxFPS}<1)
|
&&($monitor->{MaxFPS}>0)
|
||||||
) ? (3/$monitor->{MaxFPS})
|
&&($monitor->{MaxFPS}<1)
|
||||||
: $Config{ZM_WATCH_MAX_DELAY}
|
) ? (3/$monitor->{MaxFPS})
|
||||||
|
: $Config{ZM_WATCH_MAX_DELAY}
|
||||||
;
|
;
|
||||||
my $image_delay = $now-$capture_time;
|
my $image_delay = $now-$capture_time;
|
||||||
Debug("Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay");
|
Debug("Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay");
|
||||||
|
|
Loading…
Reference in New Issue