Class: DTR::Agent::Brain
Instance Method Summary
collapse
#relax, #sleep?, #wakeup?
Constructor Details
#initialize(runner_names, agent_env_setup_cmd) ⇒ Brain
Returns a new instance of Brain.
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/dtr/agent/brain.rb', line 21
def initialize(runner_names, agent_env_setup_cmd)
raise 'No runner? What can I do for you?' if runner_names.blank?
@runner_names = runner_names
@agent_env_setup_cmd = agent_env_setup_cmd
DTR.info {""}
DTR.info {"--------------------beautiful line--------------------------"}
DTR.info {"=> Agent environment setup command: #{@agent_env_setup_cmd}"}
DTR.info {"=> Runner names: #{@runner_names.join(', ')}"}
DTR.info {"=> Broadcast list: #{DTR.configuration.broadcast_list.inspect}"}
DTR.info {"=> Listening port: #{DTR.configuration.agent_listen_port}"}
DTR.info {"=> Group: #{DTR.configuration.group}"}
end
|
Instance Method Details
#hypnotize ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/dtr/agent/brain.rb', line 34
def hypnotize
loop do
if wakeup?
DTR.info {"Agent brain wakes up"}
work(DTR.fork_process { Worker.new(@runner_names, @agent_env_setup_cmd).launch })
DTR.info {"Agent brain is going to sleep"}
end
end
rescue Interrupt, SystemExit, SignalException
ensure
relax
end
|
#work(worker) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/dtr/agent/brain.rb', line 47
def work(worker)
until sleep?
end
ensure
DTR.info {"Killing worker"}
DTR.kill_process worker
end
|