diff options
author | Saku Ytti <saku@ytti.fi> | 2015-02-22 12:12:26 +0200 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2015-02-22 12:12:26 +0200 |
commit | 6634f355d99ede5ad6cd6149324d028e455c6eee (patch) | |
tree | 6836940ddb7b7b82206be3fb5b1a9067ae2c5a88 /lib | |
parent | 5fe82dcf54beecbd24d30f8715aabeac12ecb33f (diff) |
Allow node to be removed while collecting
Closes #68 (hopefully at least)
Further, our TODO to refactor/redesign the code to move state from
memory to disk should help.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/oxidized/worker.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/oxidized/worker.rb b/lib/oxidized/worker.rb index 8fe7ab5..99fc8b8 100644 --- a/lib/oxidized/worker.rb +++ b/lib/oxidized/worker.rb @@ -3,12 +3,14 @@ module Oxidized require 'oxidized/jobs' class Worker MAX_INTER_JOB_GAP = 300 + def initialize nodes @nodes = nodes @jobs = Jobs.new CFG.threads, CFG.interval, @nodes @last = Time.now.utc Thread.abort_on_exception = true end + def work ended = [] @jobs.delete_if { |job| ended << job if not job.alive? } @@ -28,6 +30,7 @@ module Oxidized @jobs.push Job.new node end end + def process job node = job.node node.last = job @@ -53,6 +56,9 @@ module Oxidized end Log.warn msg end + rescue NodeNotFound + Log.warn "#{node.name} not found, removed while collecting?" end + end end |