use FS::Record qw( qsearch str2time_sql str2time_sql_closing concat_sql );
use FS::torrus_srvderive;
-our $DEBUG = 2;
+our $DEBUG = 1;
my $user = shift or die &usage;
$FS::Daemon::PID_NEWSTYLE = 1;
-daemonize1('freeside-torrus-srvderive');
+daemonize1('torrus-srvderive');
drop_root();
AND ABS( $_date - $other_date ) <= 60
)
ORDER BY srv_date, srv_time
- LIMIT 100
+ LIMIT 10
";
while (1) {
$sth->execute($serviceid, $serviceid) or die $sth->errstr;
my $prev = 0;
while ( my $row = $sth->fetchrow_arrayref ) {
- $found++;
my( $srv_date, $srv_time ) = @$row;
my $cur = str2time( "$srv_date $srv_time" );
next if $cur-$prev <= 60;
warn "no $serviceid for $srv_date $srv_time; adding\n"
if $DEBUG;
+ $found++;
my @serviceids = $torrus_srvderive->component_serviceids;
";
my @param = ( time2str('%Y-%m-%d', $cur), #srv_date
time2str('%X', $cur), #srv_time
- $serviceid,
+ "$serviceid$dir",
300, #intvl ...
);
- warn $isql. ' with param '. @param. "\n"
+ warn $isql. ' with param '. join(',',@param). "\n"
if $DEBUG > 1;
my $isth = dbh->prepare($isql) or die $DBI::errstr; #better recovery?
$isth->execute( @param ) or die $isth->errstr;
+ dbh->commit or die dbh->errstr;
}
myexit() if sigterm() || sigint();
- sleep 60; # unless $found;
+ sleep 60 unless $found;
}
sub _shouldrun {