X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-torrus-srvderive;h=80f222b1c7f5dc8a8b5faf3abad62d80da45e2fb;hb=8ce2222eeeb5039e160357d972b7eaa680214e2c;hp=e5a05d078938f808f31a83eceb47898fd25e10a9;hpb=3d6aa5f93ba2971c43514a5d70ec5398607c4747;p=freeside.git diff --git a/FS/bin/freeside-torrus-srvderive b/FS/bin/freeside-torrus-srvderive index e5a05d078..80f222b1c 100644 --- a/FS/bin/freeside-torrus-srvderive +++ b/FS/bin/freeside-torrus-srvderive @@ -11,7 +11,8 @@ use FS::Record qw( qsearch str2time_sql str2time_sql_closing concat_sql ); use FS::torrus_srvderive; our $DEBUG = 2; -our $max_kids = 3; +our $max_kids = 6; +our $search_timeout = 30*60; # 15*60 5*60; #$torrus_srvderive->last_srv_date ? 5*60 : 15*60); our %kids; my $user = shift or die &usage; @@ -59,8 +60,13 @@ my $sql = " my $orderlimit = " ORDER BY srv_date, srv_time - LIMIT 50 -"; + LIMIT 100 +"; #50? + +if ( driver_name eq 'mysql' ) { + dbh->do('SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); + dbh->commit or die dbh->errstr; +} our $kids = 0; @@ -74,7 +80,8 @@ while (1) { &reap_kids; if ( $kids >= $max_kids ) { - sleep 10; + sleep 5; + myexit() if sigterm() || sigint(); redo; } @@ -99,6 +106,12 @@ while (1) { my @serviceids = $torrus_srvderive->component_serviceids; exit unless @serviceids; #don't try to search for empty virtual ports + #nonlocking select statements; rows in this table never change + if ( driver_name eq 'mysql' ) { + dbh->do('SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); + dbh->commit or die dbh->errstr; + } + my @in = (); for my $dir ('_IN', '_OUT') { push @in, map dbh->quote("$_$dir"), @serviceids; @@ -144,7 +157,7 @@ while (1) { eval { my $h = set_sig_handler( 'ALRM', sub { die "_timeout\n"; } ); - alarm(10*60); #5*60); #$torrus_srvderive->last_srv_date ? 5*60 : 15*60); + alarm($search_timeout); $sth->execute($serviceid, $serviceid) or die $sth->errstr; alarm(0); }; @@ -163,7 +176,7 @@ while (1) { die $@; } - warn "search finished; checking results\n" if $DEBUG; + warn "search for $serviceid finished; checking results\n" if $DEBUG; my $prev = 0; while ( my $row = $sth->fetchrow_arrayref ) { @@ -236,7 +249,7 @@ while (1) { myexit() if sigterm() || sigint(); warn "restarting main loop\n" if $DEBUG > 1; - sleep 60 unless $found; + #sleep 60 unless $found; } sub _shouldrun {