projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't redirect to a GET with sensitive data, RT#26099
[freeside.git]
/
FS
/
bin
/
freeside-queued
diff --git
a/FS/bin/freeside-queued
b/FS/bin/freeside-queued
index
ffd017a
..
23a3b3b
100644
(file)
--- a/
FS/bin/freeside-queued
+++ b/
FS/bin/freeside-queued
@@
-11,6
+11,8
@@
use FS::Conf;
use FS::Record qw(qsearch);
use FS::queue;
use FS::queue_depend;
use FS::Record qw(qsearch);
use FS::queue;
use FS::queue_depend;
+use FS::Log;
+use FS::Cron::expire_user_pref qw( expire_user_pref );
# no autoloading for non-FS classes...
use Net::SSH 0.07;
# no autoloading for non-FS classes...
use Net::SSH 0.07;
@@
-45,6
+47,7
@@
while ( $@ ) {
}
}
}
}
+my $log = FS::Log->new('queue');
logfile( "%%%FREESIDE_LOG%%%/queuelog.". $FS::UID::datasrc );
warn "completing daemonization (detaching))\n" if $DEBUG;
logfile( "%%%FREESIDE_LOG%%%/queuelog.". $FS::UID::datasrc );
warn "completing daemonization (detaching))\n" if $DEBUG;
@@
-64,6
+67,7
@@
while (1) {
if ( $kids >= $max_kids ) {
warn "WARNING: maximum $kids children reached\n" unless $warnkids++;
&reap_kids;
if ( $kids >= $max_kids ) {
warn "WARNING: maximum $kids children reached\n" unless $warnkids++;
&reap_kids;
+ expire_user_pref() unless $warnkids % 10;
sleep 1; #waiting for signals is cheap
next;
}
sleep 1; #waiting for signals is cheap
next;
}
@@
-129,12
+133,15
@@
while (1) {
undef $FS::UID::dbh;
next;
};
undef $FS::UID::dbh;
next;
};
+ expire_user_pref();
sleep $sleep_time;
next;
}
foreach my $job ( @jobs ) {
sleep $sleep_time;
next;
}
foreach my $job ( @jobs ) {
+ $log->debug('locking queue job', object => $job);
+
my %hash = $job->hash;
$hash{'status'} = 'locked';
my $ljob = new FS::queue ( \%hash );
my %hash = $job->hash;
$hash{'status'} = 'locked';
my $ljob = new FS::queue ( \%hash );
@@
-186,7
+193,7
@@
while (1) {
dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile');
#auto-use classes...
dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile');
#auto-use classes...
- if ( $ljob->job =~ /(FS::(part_export|cust_main)::\w+)::/
+ if ( $ljob->job =~ /(FS::(part_export|cust_main
|cust_pkg|Cron
)::\w+)::/
|| $ljob->job =~ /(FS::\w+)::/
)
{
|| $ljob->job =~ /(FS::\w+)::/
)
{
@@
-205,13
+212,19
@@
while (1) {
}
my $eval = "&". $ljob->job. '(@args);';
}
my $eval = "&". $ljob->job. '(@args);';
+ # don't put @args in the log, may expose passwords
+ $log->info('starting job ('.$ljob->job.')');
warn 'running "&'. $ljob->job. '('. join(', ', @args). ")\n" if $DEBUG;
eval $eval; #throw away return value? suppose so
if ( $@ ) {
warn 'running "&'. $ljob->job. '('. join(', ', @args). ")\n" if $DEBUG;
eval $eval; #throw away return value? suppose so
if ( $@ ) {
- warn "job $eval failed";
my %hash = $ljob->hash;
my %hash = $ljob->hash;
- $hash{'status'} = 'failed';
$hash{'statustext'} = $@;
$hash{'statustext'} = $@;
+ if ( $hash{'statustext'} =~ /\/misc\/queued_report/ ) { #use return?
+ $hash{'status'} = 'done';
+ } else {
+ $hash{'status'} = 'failed';
+ warn "job $eval failed";
+ }
my $fjob = new FS::queue( \%hash );
my $error = $fjob->replace($ljob);
die $error if $error;
my $fjob = new FS::queue( \%hash );
my $error = $fjob->replace($ljob);
die $error if $error;