Class: Eye::ChildProcess
- Includes:
- Celluloid, Process::Commands, Process::Config, Process::Data, Process::Notify, Process::Scheduler, Process::System, Process::Watchers
- Defined in:
- lib/eye/child_process.rb
Constant Summary
Constants included from Process::Notify
Constants included from Process::Config
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#watchers ⇒ Object
readonly
Returns the value of attribute watchers.
Attributes included from Process::Scheduler
#current_scheduled_command, #last_scheduled_at, #last_scheduled_command, #last_scheduled_reason
Instance Method Summary collapse
- #delete ⇒ Object
- #destroy ⇒ Object
-
#initialize(pid, config = {}, logger_prefix = nil, parent_pid = nil) ⇒ ChildProcess
constructor
A new instance of ChildProcess.
- #logger_tag ⇒ Object
- #monitor ⇒ Object
-
#prepare_command(command) ⇒ Object
override.
- #restart ⇒ Object
- #send_command(command, *args) ⇒ Object
- #signal(sig) ⇒ Object
- #start ⇒ Object
- #state ⇒ Object
- #status_data(debug = false) ⇒ Object
- #stop ⇒ Object
- #unmonitor ⇒ Object
- #up? ⇒ Boolean
Methods included from Process::Scheduler
included, #schedule, #schedule_history, #schedule_in, #scheduled_action, #scheduler_actions_list, #scheduler_clear_pending_list
Methods included from Process::Notify
included, #notify, #notify_died
Methods included from Process::Data
#app_name, #debug_data, #environment_string, #group_name, #group_name_pure, #self_status_data, #shell_string, #sub_object?
Methods included from Process::System
#clear_pid_file, #execute, #failsafe_load_pid, #failsafe_save_pid, #load_pid_from_file, #pid_file_ctime, #process_pid_running?, #process_really_running?, #save_pid_to_file, #send_signal, #set_pid_from_file, #wait_for_condition
Methods included from Process::Watchers
#add_watchers, #remove_watchers
Methods included from Process::Config
#[], #c, #control_pid?, #prepare_config, #update_config
Methods included from Process::Commands
#restart_process, #start_process, #stop_process
Constructor Details
#initialize(pid, config = {}, logger_prefix = nil, parent_pid = nil) ⇒ ChildProcess
Returns a new instance of ChildProcess.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/eye/child_process.rb', line 29 def initialize(pid, config = {}, logger_prefix = nil, parent_pid = nil) raise 'Empty pid' unless pid @pid = pid @parent_pid = parent_pid @config = prepare_config(config) @name = "child-#{pid}" @full_name = [logger_prefix, @name] * ':' @watchers = {} debug "start monitoring CHILD config: #{@config.inspect}" start_checkers end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
27 28 29 |
# File 'lib/eye/child_process.rb', line 27 def config @config end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
27 28 29 |
# File 'lib/eye/child_process.rb', line 27 def full_name @full_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/eye/child_process.rb', line 27 def name @name end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
27 28 29 |
# File 'lib/eye/child_process.rb', line 27 def pid @pid end |
#watchers ⇒ Object (readonly)
Returns the value of attribute watchers.
27 28 29 |
# File 'lib/eye/child_process.rb', line 27 def watchers @watchers end |
Instance Method Details
#delete ⇒ Object
82 83 |
# File 'lib/eye/child_process.rb', line 82 def delete end |
#destroy ⇒ Object
85 86 87 88 |
# File 'lib/eye/child_process.rb', line 85 def destroy remove_watchers terminate end |
#logger_tag ⇒ Object
45 46 47 |
# File 'lib/eye/child_process.rb', line 45 def logger_tag full_name end |
#monitor ⇒ Object
76 77 |
# File 'lib/eye/child_process.rb', line 76 def monitor end |
#prepare_command(command) ⇒ Object
override
98 99 100 |
# File 'lib/eye/child_process.rb', line 98 def prepare_command(command) # override super.gsub('{PARENT_PID}', @parent_pid.to_s) end |
#restart ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/eye/child_process.rb', line 68 def restart if self[:restart_command] execute_restart_command else stop end end |
#send_command(command, *args) ⇒ Object
57 58 59 |
# File 'lib/eye/child_process.rb', line 57 def send_command(command, *args) schedule command, *args, Eye::Reason::User.new(command) end |
#signal(sig) ⇒ Object
90 91 92 |
# File 'lib/eye/child_process.rb', line 90 def signal(sig) send_signal(sig) if self.pid end |
#start ⇒ Object
61 62 |
# File 'lib/eye/child_process.rb', line 61 def start end |
#state ⇒ Object
49 50 51 |
# File 'lib/eye/child_process.rb', line 49 def state :up end |
#status_data(debug = false) ⇒ Object
94 95 96 |
# File 'lib/eye/child_process.rb', line 94 def status_data(debug = false) self_status_data(debug) end |
#stop ⇒ Object
64 65 66 |
# File 'lib/eye/child_process.rb', line 64 def stop kill_process end |
#unmonitor ⇒ Object
79 80 |
# File 'lib/eye/child_process.rb', line 79 def unmonitor end |
#up? ⇒ Boolean
53 54 55 |
# File 'lib/eye/child_process.rb', line 53 def up? state == :up end |