class Eye::Process
Attributes
children[RW]
config[RW]
flapping_times[RW]
name[RW]
parent_pid[RW]
pid[RW]
state_reason[RW]
states_history[RW]
triggers[RW]
watchers[RW]
Public Class Methods
new(config)
click to toggle source
Calls superclass method
# File lib/eye/process.rb, line 24 def initialize(config) raise 'you must supply a pid_file location' unless config[:pid_file] @config = prepare_config(config) @watchers = {} @children = {} @triggers = [] @name = @config[:name] @flapping_times = 0 @states_history = Eye::Process::StatesHistory.new(100) @states_history << :unmonitored debug "creating with config: #{@config.inspect}" add_triggers super() # for statemachine end
Public Instance Methods
log_transition(transition)
click to toggle source
# File lib/eye/process/states.rb, line 79 def log_transition(transition) if transition.to_name != transition.from_name || @state_reason.is_a?(Eye::Reason::User) @states_history.push transition.to_name, @state_reason info "switch :#{transition.event} [:#{transition.from_name} => :#{transition.to_name}] #{@state_reason ? "(reason: #{@state_reason})" : nil}" end end
on_crashed()
click to toggle source
# File lib/eye/process/states.rb, line 71 def on_crashed schedule :check_crash, Eye::Reason.new(:crashed) end
on_unmonitored()
click to toggle source
# File lib/eye/process/states.rb, line 75 def on_unmonitored self.pid = nil end
switch(name, reason = nil)
click to toggle source
do transition
# File lib/eye/process/states.rb, line 8 def switch(name, reason = nil) @state_reason = reason || last_scheduled_reason self.send("#{name}!") end