projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
referraldefault dropdown in config, RT#9599
[freeside.git]
/
FS
/
bin
/
freeside-cdrd
diff --git
a/FS/bin/freeside-cdrd
b/FS/bin/freeside-cdrd
index
882fd54
..
2cf75f3
100644
(file)
--- a/
FS/bin/freeside-cdrd
+++ b/
FS/bin/freeside-cdrd
@@
-2,10
+2,11
@@
use strict;
use FS::Daemon ':all'; #daemonize1 drop_root daemonize2 myexit logfile sig*
use strict;
use FS::Daemon ':all'; #daemonize1 drop_root daemonize2 myexit logfile sig*
-use FS::UID qw(
adminsuidsetup
);
-use FS::Record qw(qsearch ); #qsearchs);
+use FS::UID qw(
adminsuidsetup
);
+use FS::Record qw(
qsearch ); #qsearchs);
#use FS::cdr;
use FS::cust_pkg;
#use FS::cdr;
use FS::cust_pkg;
+use FS::queue;
my $user = shift or die &usage;
my $user = shift or die &usage;
@@
-51,8
+52,16
@@
my $extra_sql =
|| svc_phone.phonenum
)
)
|| svc_phone.phonenum
)
)
- )
+ )
+ AND 0 = (
+ SELECT COUNT(*) FROM queue
+ WHERE queue.job = 'FS::cust_main::queued_bill'
+ AND queue.custnum = cust_pkg.custnum
+ )
+
";
";
+# don't repeatedly queue failures
+# AND status != 'failed'
while (1) {
while (1) {
@@
-71,10
+80,17
@@
while (1) {
#my $work_cust_pkg = $cust_pkg;
#my $work_cust_pkg = $cust_pkg;
- my $cust_main = $cust_pkg->cust_main;
+
#
my $cust_main = $cust_pkg->cust_main;
my $time = time;
my $time = time;
- $cust_main->bill_and_collect(
+
+ my $job = new FS::queue {
+ 'job' => 'FS::cust_main::queued_bill',
+ 'secure' => 'Y',
+ 'custnum' => $cust_pkg->custnum,
+ };
+ my $error = $job->insert(
+ 'custnum' => $cust_pkg->custnum,
'time' => $time,
'invoice_time' => $time,
'actual_time' => $time,
'time' => $time,
'invoice_time' => $time,
'actual_time' => $time,
@@
-82,10
+98,17
@@
while (1) {
#'debug' => 1,
);
#'debug' => 1,
);
+ if ( $error ) {
+ #die "FATAL: error inserting billing job: $error\n";
+ warn "WARNING: error inserting billing job (will retry in 30 seconds):".
+ " $error\n";
+ sleep 30; #i dunno, wait and see if the database comes back?
+ }
+
}
myexit() if sigterm() || sigint();
}
myexit() if sigterm() || sigint();
- sleep
5; #
unless $found;
+ sleep
1
unless $found;
}
}
@@
-114,21
+137,21
@@
sub _shouldrun {
}
sub usage {
}
sub usage {
- die "Usage:\n\n freeside-
prepaid
d user\n";
+ die "Usage:\n\n freeside-
cdr
d user\n";
}
=head1 NAME
}
=head1 NAME
-freeside-
prepaidd - Real-time daemon for prepaid package
s
+freeside-
cdrd - Real-time daemon for CDR
s
=head1 SYNOPSIS
=head1 SYNOPSIS
- freeside-
prepaid
d
+ freeside-
cdr
d
=head1 DESCRIPTION
=head1 DESCRIPTION
-Runs continuously
and suspends or cancels any prepaid customer packages which
-
have passed their renewal date (next bill date)
.
+Runs continuously
, searches for CDRs and bills customers who have VoIP
+
price plands with the B<bill_every_call> option set
.
=head1 SEE ALSO
=head1 SEE ALSO