diff options
author | ytti <saku@ytti.fi> | 2017-02-11 04:43:49 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-11 04:43:49 +0400 |
commit | 6f67c1a9f8288b8a090f4834caba4b7f181ddf18 (patch) | |
tree | ab4825f4bc6a79a48bedd7fe92fc36eeafb513f2 /lib/oxidized | |
parent | e6e72296d7e22eaa6fe20fd0b2007d3b58a078a2 (diff) | |
parent | 64fc260a4da53af34f1f8288d4ec68c6583907ee (diff) |
Merge pull request #715 from Netflix-Skunkworks/only-next-with-new-thread
Next with new thread functionality (v2)
Diffstat (limited to 'lib/oxidized')
-rw-r--r-- | lib/oxidized/config.rb | 5 | ||||
-rw-r--r-- | lib/oxidized/nodes.rb | 3 | ||||
-rw-r--r-- | lib/oxidized/worker.rb | 5 |
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb index b6b5c40..aba8b63 100644 --- a/lib/oxidized/config.rb +++ b/lib/oxidized/config.rb @@ -28,8 +28,9 @@ module Oxidized asetus.default.retries = 3 asetus.default.prompt = /^([\w.@-]+[#>]\s?)$/ asetus.default.rest = '127.0.0.1:8888' # or false to disable - asetus.default.vars = {} # could be 'enable'=>'enablePW' - asetus.default.groups = {} # group level configuration + asetus.default.next_adds_job = false # if true, /next adds job, so device is fetched immmeiately + asetus.default.vars = {} # could be 'enable'=>'enablePW' + asetus.default.groups = {} # group level configuration asetus.default.pid = File.join(Oxidized::Config::Root, 'pid') asetus.default.input.default = 'ssh, telnet' diff --git a/lib/oxidized/nodes.rb b/lib/oxidized/nodes.rb index f5a1ad0..6751c7a 100644 --- a/lib/oxidized/nodes.rb +++ b/lib/oxidized/nodes.rb @@ -4,7 +4,7 @@ module Oxidized class Oxidized::NotSupported < OxidizedError; end class Oxidized::NodeNotFound < OxidizedError; end class Nodes < Array - attr_accessor :source + attr_accessor :source, :jobs alias :put :unshift def load node_want=nil with_lock do @@ -73,6 +73,7 @@ module Oxidized # set last job to nil so that the node is picked for immediate update n.last = nil put n + jobs.want += 1 if Oxidized.config.next_adds_job? end end end diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index 1952d01..80d65cb 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -3,8 +3,9 @@ module Oxidized require 'oxidized/jobs' class Worker def initialize nodes - @nodes = nodes - @jobs = Jobs.new(Oxidized.config.threads, Oxidized.config.interval, @nodes) + @nodes = nodes + @jobs = Jobs.new(Oxidized.config.threads, Oxidized.config.interval, @nodes) + @nodes.jobs = @jobs Thread.abort_on_exception = true end |