Class: ScoutAgent::Agent::MasterAgent
Instance Attribute Summary
#log
Instance Method Summary
collapse
#authorize
Methods included from Tracked
#clear_status, #force_status_database_reload, #status, #status_database, #status_log
Constructor Details
Returns a new instance of MasterAgent.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/scout_agent/agent/master_agent.rb', line 10
def initialize
super
@running = true
@main_loop = nil
@server = Server.new(log)
@db = Database.load(:mission_log, log)
@queue = Database.load(:queue, log)
@snapshots = Database.load(:snapshots, log)
if [@db, @queue, @snapshots].any? { |db| db.nil? }
log.fatal("Could not load all required databases.")
exit
end
end
|
Instance Method Details
#finish ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/scout_agent/agent/master_agent.rb', line 50
def finish
if @running
log.info("Shutting down.")
else
log.warn("Received multiple shutdown signals.")
end
@running = false
notice_changes
end
|
#notice_changes ⇒ Object
44
45
46
47
48
|
# File 'lib/scout_agent/agent/master_agent.rb', line 44
def notice_changes
@main_loop.run if @main_loop
rescue ThreadError end
|
#run ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/scout_agent/agent/master_agent.rb', line 26
def run
log.info("Running.")
@main_loop = Thread.new do
Thread.current.abort_on_exception = true
loop do
%w[ fetch_plan
execute_missions
checkin
perform_maintenance
wait_for_orders ].each do |stage|
send(stage)
check_running_status
end
end
end
@main_loop.join
end
|