Lines 75-80
try {
Link Here
|
75 |
}; |
75 |
}; |
76 |
|
76 |
|
77 |
if ( $conn ) { |
77 |
if ( $conn ) { |
|
|
78 |
# process outstanding jobs on startup |
79 |
process_outstanding; |
80 |
|
78 |
# FIXME cf note in Koha::BackgroundJob about $namespace |
81 |
# FIXME cf note in Koha::BackgroundJob about $namespace |
79 |
my $namespace = C4::Context->config('memcached_namespace'); |
82 |
my $namespace = C4::Context->config('memcached_namespace'); |
80 |
for my $queue (@queues) { |
83 |
for my $queue (@queues) { |
Lines 100-110
while (1) {
Link Here
|
100 |
$conn->ack( { frame => $frame } ); # FIXME depending on success? |
103 |
$conn->ack( { frame => $frame } ); # FIXME depending on success? |
101 |
|
104 |
|
102 |
} else { |
105 |
} else { |
103 |
my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues }); |
106 |
process_outstanding; |
104 |
while ( my $job = $jobs->next ) { |
|
|
105 |
my $args = decode_json($job->data); |
106 |
process_job( $job, { job_id => $job->id, %$args } ); |
107 |
} |
108 |
sleep 10; |
107 |
sleep 10; |
109 |
} |
108 |
} |
110 |
} |
109 |
} |
Lines 124-126
sub process_job {
Link Here
|
124 |
$job->process( $args ); |
123 |
$job->process( $args ); |
125 |
exit; |
124 |
exit; |
126 |
} |
125 |
} |
127 |
- |
126 |
|
|
|
127 |
sub process_outstanding { |
128 |
my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues }); |
129 |
while ( my $job = $jobs->next ) { |
130 |
my $args = decode_json($job->data); |
131 |
process_job( $job, { job_id => $job->id, %$args } ); |
132 |
} |
133 |
return 1; |
134 |
} |