summaryrefslogtreecommitdiff
path: root/FS/bin/freeside-queued
diff options
context:
space:
mode:
authorivan <ivan>2009-04-17 19:50:21 +0000
committerivan <ivan>2009-04-17 19:50:21 +0000
commit83cf53bba06bd40c34e547f2ae18cd4a59109ff7 (patch)
treeb924ee80e0c40931953cafb00920aa8a2d77b9c7 /FS/bin/freeside-queued
parentcf8a89b64ab5cc9c4ffe153023706d943fa1f53a (diff)
add priority to job queue so billing jobs don't don't drown out provisioning jobs
Diffstat (limited to 'FS/bin/freeside-queued')
-rw-r--r--FS/bin/freeside-queued21
1 files changed, 13 insertions, 8 deletions
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
index 93d735d1a..4093e5aa8 100644
--- a/FS/bin/freeside-queued
+++ b/FS/bin/freeside-queued
@@ -89,14 +89,19 @@ while (1) {
my $nodepend = 'AND 0 = ( SELECT COUNT(*) FROM queue_depend'.
' WHERE queue_depend.jobnum = queue.jobnum ) ';
- my $job = qsearchs(
- 'queue',
- { 'status' => 'new' },
- '',
- driver_name eq 'mysql'
- ? "$nodepend ORDER BY jobnum LIMIT 1 FOR UPDATE"
- : "$nodepend ORDER BY jobnum FOR UPDATE LIMIT 1"
- ) or do {
+ #anything with a priority goes after stuff without one
+ my $order_by = ' ORDER BY COALESCE(priority,0) ASC, jobnum ASC ';
+
+ $order_by .= ( driver_name eq 'mysql'
+ ? ' LIMIT 1 FOR UPDATE '
+ : ' FOR UPDATE LIMIT 1 ' );
+
+ my $job = qsearchs({
+ 'table' => 'queue',
+ 'hashref' => { 'status' => 'new' },
+ 'extra_sql' => $nodepend,
+ 'order_by' => $order_by,
+ }) or do {
# if $oldAutoCommit {
dbh->commit or do {
warn "WARNING: database error, closing connection: ". dbh->errstr;