Class: ScoutAgent::Agent
- Inherits:
-
Object
- Object
- ScoutAgent::Agent
- 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
Defined Under Namespace
Classes: CommunicationAgent, MasterAgent
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
The log file this agent will report to.
Instance Method Summary collapse
-
#authorize ⇒ Object
Ensure we are the only process with this name running.
-
#finish ⇒ Object
This method will be called when the agent receives a
TERM
signal. -
#initialize ⇒ Agent
constructor
Prepares a new agent instance by building a log() and setting a
"Loading"
status message. -
#notice_changes ⇒ Object
This method will be called when the agent process receives an
ALRM
signal.
Methods included from Tracked
#clear_status, #force_status_database_reload, #status, #status_database, #status_log
Constructor Details
#initialize ⇒ Agent
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
#log ⇒ Object (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
#authorize ⇒ Object
Ensure we are the only process with this name running.
30 31 32 |
# File 'lib/scout_agent/agent.rb', line 30 def IDCard.new(file_name). or exit(1) end |
#finish ⇒ Object
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_changes ⇒ Object
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 |