random() and LIMIT the number of daemon jobs requested from Netdisco queue

This commit is contained in:
Oliver Gorwits
2013-02-23 23:53:59 +00:00
parent 992086084b
commit 6507ac22a6
4 changed files with 18 additions and 3 deletions

View File

@@ -32,10 +32,14 @@ sub worker_begin {
sub worker_body {
my $self = shift;
my $num_slots = $self->do('num_workers') - 1;
# get all pending jobs
# get some pending jobs
my $rs = schema('netdisco')->resultset('Admin')
->search({status => 'queued'});
->search(
{status => 'queued'},
{order_by => 'random()', rows => $num_slots},
);
while (1) {
while (my $job = $rs->next) {