Class: Eye::Process
- Extended by:
- Validate
- Includes:
- Celluloid, Children, Commands, Config, Controller, Data, Monitor, Notify, Scheduler, System, Trigger, Watchers
- Defined in:
- lib/eye/process.rb,
lib/eye/process/states.rb
Defined Under Namespace
Modules: Children, Commands, Config, Controller, Data, Monitor, Notify, Scheduler, System, Trigger, Validate, Watchers Classes: StatesHistory
Constant Summary
Constants included from Notify
Constants included from Config
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#config ⇒ Object
Returns the value of attribute config.
-
#flapping_times ⇒ Object
Returns the value of attribute flapping_times.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#state_reason ⇒ Object
Returns the value of attribute state_reason.
-
#states_history ⇒ Object
Returns the value of attribute states_history.
-
#triggers ⇒ Object
Returns the value of attribute triggers.
-
#watchers ⇒ Object
Returns the value of attribute watchers.
Attributes included from Scheduler
#current_scheduled_command, #last_scheduled_at, #last_scheduled_command, #last_scheduled_reason
Instance Method Summary collapse
-
#initialize(config) ⇒ Process
constructor
A new instance of Process.
- #log_transition(transition) ⇒ Object
- #on_crashed ⇒ Object
- #on_unmonitored ⇒ Object
-
#switch(name, reason = nil) ⇒ Object
do transition.
Methods included from Validate
Methods included from Scheduler
included, #schedule, #schedule_history, #schedule_in, #scheduled_action, #scheduler_actions_list, #scheduler_clear_pending_list
Methods included from Notify
Methods included from Trigger
#add_triggers, #check_triggers, #remove_triggers, #retry_start_after_flapping
Methods included from Children
#add_children, #add_or_update_children, #remove_child, #remove_children
Methods included from System
#clear_pid_file, #execute, #failsafe_load_pid, #failsafe_save_pid, #load_pid_from_file, #pid_file_ctime, #process_really_running?, #save_pid_to_file, #send_signal, #set_pid_from_file, #wait_for_condition
Methods included from Watchers
#add_watchers, #remove_watchers
Methods included from Controller
#delete, #monitor, #restart, #send_command, #signal, #start, #stop, #unmonitor
Methods included from Commands
#restart_process, #start_process, #stop_process
Methods included from Data
#app_name, #debug_data, #full_name, #group_name, #logger_tag, #self_status_data, #status_data, #sub_object?
Methods included from Config
#[], #c, #control_pid?, #prepare_config, #update_config
Constructor Details
#initialize(config) ⇒ Process
Returns a new instance of Process.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/eye/process.rb', line 23 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 |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
20 21 22 |
# File 'lib/eye/process.rb', line 20 def children @children end |
#config ⇒ Object
Returns the value of attribute config.
20 21 22 |
# File 'lib/eye/process.rb', line 20 def config @config end |
#flapping_times ⇒ Object
Returns the value of attribute flapping_times.
20 21 22 |
# File 'lib/eye/process.rb', line 20 def flapping_times @flapping_times end |
#name ⇒ Object
Returns the value of attribute name.
20 21 22 |
# File 'lib/eye/process.rb', line 20 def name @name end |
#pid ⇒ Object
Returns the value of attribute pid.
20 21 22 |
# File 'lib/eye/process.rb', line 20 def pid @pid end |
#state_reason ⇒ Object
Returns the value of attribute state_reason.
20 21 22 |
# File 'lib/eye/process.rb', line 20 def state_reason @state_reason end |
#states_history ⇒ Object
Returns the value of attribute states_history.
20 21 22 |
# File 'lib/eye/process.rb', line 20 def states_history @states_history end |
#triggers ⇒ Object
Returns the value of attribute triggers.
20 21 22 |
# File 'lib/eye/process.rb', line 20 def triggers @triggers end |
#watchers ⇒ Object
Returns the value of attribute watchers.
20 21 22 |
# File 'lib/eye/process.rb', line 20 def watchers @watchers end |
Instance Method Details
#log_transition(transition) ⇒ Object
78 79 80 81 |
# File 'lib/eye/process/states.rb', line 78 def log_transition(transition) @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 |
#on_crashed ⇒ Object
70 71 72 |
# File 'lib/eye/process/states.rb', line 70 def on_crashed schedule :check_crash, Eye::Reason.new(:crashed) end |
#on_unmonitored ⇒ Object
74 75 76 |
# File 'lib/eye/process/states.rb', line 74 def on_unmonitored self.pid = nil end |
#switch(name, reason = nil) ⇒ Object
do transition
7 8 9 10 |
# File 'lib/eye/process/states.rb', line 7 def switch(name, reason = nil) @state_reason = reason || last_scheduled_reason self.send("#{name}!") end |