i hate mysql
[freeside.git] / FS / bin / freeside-torrus-srvderive
index e83318f..e8626e1 100644 (file)
@@ -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;
@@ -75,6 +76,7 @@ while (1) {
     &reap_kids;
     if ( $kids >= $max_kids ) {
       sleep 5;
+      myexit() if sigterm() || sigint();
       redo;
     }
 
@@ -148,7 +150,7 @@ while (1) {
 
       eval {
         my $h = set_sig_handler( 'ALRM', sub { die "_timeout\n"; } );
-        alarm(15*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);
       };
@@ -240,7 +242,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 {