Class: DTR::Agent::Worker
Overview
Worker watchs runner processes.
Instance Method Summary collapse
-
#initialize ⇒ Worker
constructor
A new instance of Worker.
- #watch_runners ⇒ Object
Constructor Details
#initialize ⇒ Worker
Returns a new instance of Worker.
20 21 22 |
# File 'lib/dtr/agent/worker.rb', line 20 def initialize @runners_group = ThreadGroup.new end |
Instance Method Details
#watch_runners ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dtr/agent/worker.rb', line 24 def watch_runners DTR.configuration.agent_runners.each do |name| runner_thread = Thread.start { DTR.run_script("DTR::Agent::Runner.new(#{name.inspect}).start") } runner_thread[:runner_name] = name @runners_group.add runner_thread end yield while @runners_group.list.length > 0 alive_runners = @runners_group.list.collect {|r| r[:runner_name]} DTR.info { "Waiting for #{alive_runners.join(', ').downcase} shutdown" } sleep 1 end end |