class Eye::Process
Attributes
children[RW]
config[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 25 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] @states_history = Eye::Process::StatesHistory.new(100) @states_history << :unmonitored @state_call = {} 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 81 def log_transition(transition) if transition.to_name != transition.from_name || @state_call[:by] == :user reason_str = reason_from_call(@state_call) @states_history.push transition.to_name, reason_str info "switch :#{transition.event} [:#{transition.from_name} => :#{transition.to_name}] #{reason_str}" end end
on_crashed()
click to toggle source
# File lib/eye/process/states.rb, line 72 def on_crashed self.pid = nil schedule command: :check_crash, reason: :crashed end
on_unmonitored()
click to toggle source
# File lib/eye/process/states.rb, line 77 def on_unmonitored self.pid = nil end
switch(name, call = {})
click to toggle source
do transition
# File lib/eye/process/states.rb, line 9 def switch(name, call = {}) @state_call = @last_scheduled_call ? @last_scheduled_call.merge(call) : call self.send("#{name}!") end