Class: ScoutAgent::Agent

Inherits:
Object
  • Object
show all
Includes:
Tracked
Defined in:
lib/scout_agent/agent.rb,
lib/scout_agent/agent/master_agent.rb,
lib/scout_agent/agent/communication_agent.rb

Overview

An Agent is a subprocess launched at startup and kept running by a Lifeline monitor. These subprocesses manage the major functions of the platform.

Direct Known Subclasses

CommunicationAgent, MasterAgent

Defined Under Namespace

Classes: CommunicationAgent, MasterAgent

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Tracked

#clear_status, #force_status_database_reload, #status, #status_database, #status_log

Constructor Details

#initializeAgent

Prepares a new agent instance by building a log() and setting a "Loading" status message.



16
17
18
19
20
21
22
23
24
# File 'lib/scout_agent/agent.rb', line 16

def initialize
  @log = ScoutAgent.prepare_wire_tap(file_name)
  log.info("Loading.")

  status("Loading", file_name)
  at_my_exit do
    clear_status(file_name)
  end
end

Instance Attribute Details

#logObject (readonly)

The log file this agent will report to.



27
28
29
# File 'lib/scout_agent/agent.rb', line 27

def log
  @log
end

Instance Method Details

#authorizeObject

Ensure we are the only process with this name running.



30
31
32
# File 'lib/scout_agent/agent.rb', line 30

def authorize
  IDCard.new(file_name).authorize or exit(1)
end

#finishObject

This method will be called when the agent receives a TERM signal. The default behavior is to exit(), but subclasses can override it to add more specific behavior.



48
49
50
# File 'lib/scout_agent/agent.rb', line 48

def finish
  exit
end

#notice_changesObject

This method will be called when the agent process receives an ALRM signal. By default, this method is a no-op, but subclasses can overrided it to add behavior.



39
40
41
# File 'lib/scout_agent/agent.rb', line 39

def notice_changes
  # do nothing:  specific agents can override for their purposes
end