[#209] AUTO broken in tasks specification
This commit is contained in:
		@@ -44,9 +44,8 @@ sub worker_body {
 | 
			
		||||
      prctl sprintf 'netdisco-daemon: worker #%s manager: gathering', $wid;
 | 
			
		||||
      my $num_slots = 0;
 | 
			
		||||
 | 
			
		||||
      $num_slots =
 | 
			
		||||
        MCE::Util::_parse_max_workers( setting('workers')->{tasks} )
 | 
			
		||||
          - $self->{queue}->pending();
 | 
			
		||||
      $num_slots = parse_max_workers( setting('workers')->{tasks} )
 | 
			
		||||
                     - $self->{queue}->pending();
 | 
			
		||||
      debug "mgr ($wid): getting potential jobs for $num_slots workers (HP)";
 | 
			
		||||
 | 
			
		||||
      # get some high priority jobs
 | 
			
		||||
@@ -62,9 +61,8 @@ sub worker_body {
 | 
			
		||||
          $self->{queue}->enqueuep(100, $job);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      $num_slots =
 | 
			
		||||
        MCE::Util::_parse_max_workers( setting('workers')->{tasks} )
 | 
			
		||||
          - $self->{queue}->pending();
 | 
			
		||||
      $num_slots = parse_max_workers( setting('workers')->{tasks} )
 | 
			
		||||
                     - $self->{queue}->pending();
 | 
			
		||||
      debug "mgr ($wid): getting potential jobs for $num_slots workers (NP)";
 | 
			
		||||
 | 
			
		||||
      # get some normal priority jobs
 | 
			
		||||
 
 | 
			
		||||
@@ -3,11 +3,13 @@ package App::Netdisco::Util::Daemon;
 | 
			
		||||
use strict;
 | 
			
		||||
use warnings;
 | 
			
		||||
 | 
			
		||||
use MCE::Util ();
 | 
			
		||||
 | 
			
		||||
# make sure this is already done elsewhere
 | 
			
		||||
use if $^O eq 'linux', 'Sys::Proctitle';
 | 
			
		||||
 | 
			
		||||
use base 'Exporter';
 | 
			
		||||
our @EXPORT = 'prctl';
 | 
			
		||||
our @EXPORT = qw/prctl parse_max_workers/;
 | 
			
		||||
 | 
			
		||||
sub prctl {
 | 
			
		||||
  if ($^O eq 'linux') {
 | 
			
		||||
@@ -18,4 +20,19 @@ sub prctl {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub parse_max_workers {
 | 
			
		||||
  my $max = shift;
 | 
			
		||||
  return 0 if !defined $max;
 | 
			
		||||
 | 
			
		||||
  if ($max =~ /^auto(?:$|\s*([\-\+\/\*])\s*(.+)$)/i) {
 | 
			
		||||
      my $ncpu = MCE::Util::get_ncpu() || 0;
 | 
			
		||||
 | 
			
		||||
      if ($1 and $2) {
 | 
			
		||||
          local $@; $max = eval "int($ncpu $1 $2 + 0.5)";
 | 
			
		||||
      }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return $max || 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
1;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user