Class: DTR::Agent::Worker

Inherits:
Object show all
Defined in:
lib/dtr/agent/worker.rb

Overview

Worker watchs runner processes.

Instance Method Summary collapse

Constructor Details

#initializeWorker

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_runnersObject



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