auto job priorities
This commit is contained in:
@@ -9,7 +9,7 @@ use Role::Tiny;
|
||||
use namespace::clean;
|
||||
|
||||
use App::Netdisco::JobQueue qw/jq_locked jq_getsome jq_lock/;
|
||||
use MCE::Util 'get_ncpu';
|
||||
use MCE::Util ();
|
||||
|
||||
sub worker_begin {
|
||||
my $self = shift;
|
||||
@@ -27,7 +27,7 @@ sub worker_begin {
|
||||
if (scalar @jobs) {
|
||||
info sprintf "mgr (%s): found %s jobs booked to this processing node",
|
||||
$wid, scalar @jobs;
|
||||
$self->{queue}->enqueue(@jobs); # FIXME priority and freeze
|
||||
$self->{queue}->enqueue(@jobs);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,9 @@ sub worker_body {
|
||||
return debug "mgr ($wid): no need for manager... quitting"
|
||||
if setting('workers')->{'no_manager'};
|
||||
|
||||
# FIXME really the best strategy?
|
||||
my $num_slots = (MCE::Util::get_ncpu() * 2) - $self->{queue}->pending();
|
||||
my $num_slots =
|
||||
MCE::Util::_parse_max_workers( setting('workers')->{pollers} )
|
||||
- $self->{queue}->pending();
|
||||
|
||||
while (1) {
|
||||
debug "mgr ($wid): getting potential jobs for $num_slots workers";
|
||||
@@ -55,7 +56,7 @@ sub worker_body {
|
||||
$wid, $job->id;
|
||||
|
||||
# copy job to local queue
|
||||
$self->{queue}->enqueue($job); # FIXME priority and freeze
|
||||
$self->{queue}->enqueue($job);
|
||||
}
|
||||
|
||||
debug "mgr ($wid): sleeping now...";
|
||||
|
||||
@@ -29,10 +29,18 @@ sub jq_getsome {
|
||||
|
||||
my $rs = schema('netdisco')->resultset('Admin')
|
||||
->search(
|
||||
{status => 'queued'},
|
||||
{status => 'queued', action => { -in => setting('job_prio')->{high} } },
|
||||
{order_by => 'random()', rows => ($num_slots || 1)},
|
||||
);
|
||||
|
||||
unless ($rs->count) {
|
||||
$rs = schema('netdisco')->resultset('Admin')
|
||||
->search(
|
||||
{status => 'queued', action => { -in => setting('job_prio')->{normal} } },
|
||||
{order_by => 'random()', rows => ($num_slots || 1)},
|
||||
);
|
||||
}
|
||||
|
||||
while (my $job = $rs->next) {
|
||||
push @returned, schema('daemon')->resultset('Admin')
|
||||
->new_result({ $job->get_columns });
|
||||
|
||||
@@ -25,7 +25,9 @@ sub add_job {
|
||||
});
|
||||
}
|
||||
|
||||
foreach my $action (keys %{ setting('job_types') }) {
|
||||
foreach my $action (@{ setting('job_prio')->{high} },
|
||||
@{ setting('job_prio')->{normal} }) {
|
||||
|
||||
ajax "/ajax/control/admin/$action" => require_role admin => sub {
|
||||
add_job($action, param('device'), param('extra'));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user