Class: DTR::Agent::Herald

Inherits:
Object show all
Includes:
Service::Agent, Service::WorkingEnv
Defined in:
lib/dtr/agent/herald.rb

Defined Under Namespace

Classes: WorkingEnvError

Instance Method Summary collapse

Methods included from Service::Agent

#all_agents_info, #new_agent_monitor, #provide_agent_info

Methods included from Service::Rinda

#lookup, #lookup_ring, #start_service, #stop_service

Methods included from Service::WorkingEnv

#lookup_working_env, #provide_working_env

Constructor Details

#initialize(working_env_key, agent_env_setup_cmd, runners) ⇒ Herald

Returns a new instance of Herald.



25
26
27
28
29
30
31
32
33
34
# File 'lib/dtr/agent/herald.rb', line 25

def initialize(working_env_key, agent_env_setup_cmd, runners)
  @working_env_key = working_env_key
  @agent_env_setup_cmd = agent_env_setup_cmd
  @runners = runners
  @env_store = EnvStore.new
  start_service
  start_off
ensure
  stop_service
end

Instance Method Details

#fetch_working_envObject

Raises:



50
51
52
53
54
55
56
57
# File 'lib/dtr/agent/herald.rb', line 50

def fetch_working_env
  working_env = lookup_working_env
  DTR.info {"=> Got working environment created at #{working_env[:created_at]} by #{working_env[:host]}"}

  raise WorkingEnvError.new("No test files need to load?(working env: #{working_env})") if working_env[:files].blank?
  raise WorkingEnvError.new('Setup working environment failed, no runner started.') unless working_env.setup_env(@agent_env_setup_cmd)
  working_env
end

#start_offObject



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/dtr/agent/herald.rb', line 36

def start_off
  DTR.info {"=> Herald starts off..."}
  provide_agent_info(@agent_env_setup_cmd, @runners)

  @env_store[@working_env_key] = fetch_working_env
rescue WorkingEnvError
  DTR.error $!.message
  exit(-1)
rescue
  DTR.error $!.message
  DTR.error $!.backtrace.join("\n")
  exit(-1)
end