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.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#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 = 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(opts = {}) ⇒ Object
- #stop ⇒ Object
- #unmonitor ⇒ Object
- #up? ⇒ Boolean
Methods included from Process::Scheduler
#execute_proc, included, #schedule, #schedule_history, #schedule_in, #scheduled_action, #scheduler_actions_list, #scheduler_clear_pending_list, #scheduler_freeze, #scheduler_freeze?, #scheduler_unfreeze
Methods included from Process::Notify
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, #compare_identity, #daemonize, #execute, #execute_async, #execute_sync, #expand_path, #failsafe_load_pid, #failsafe_save_pid, #get_identity, #load_pid_from_file, #pid_file_ctime, #process_pid_running?, #process_really_running?, #save_pid_to_file, #send_signal, #wait_for_condition
Methods included from Process::Watchers
#add_watchers, #remove_watchers
Methods included from Process::Config
#[], #c, #control_pid?, #prepare_config, #skip_group_action?, #update_config
Methods included from Process::Commands
#restart_process, #start_process, #stop_process
Constructor Details
#initialize(pid, config = {}, logger_prefix = nil, parent = nil) ⇒ ChildProcess
Returns a new instance of ChildProcess.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/eye/child_process.rb', line 30 def initialize(pid, config = {}, logger_prefix = nil, parent = nil) raise 'Empty pid' unless pid @pid = pid @parent = parent @config = prepare_config(config) @name = "child-#{pid}" @full_name = [logger_prefix, @name].join(':') @watchers = {} debug { "start monitoring CHILD config: #{@config.inspect}" } start_checkers end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
28 29 30 |
# File 'lib/eye/child_process.rb', line 28 def config @config end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
28 29 30 |
# File 'lib/eye/child_process.rb', line 28 def full_name @full_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/eye/child_process.rb', line 28 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
28 29 30 |
# File 'lib/eye/child_process.rb', line 28 def parent @parent end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
28 29 30 |
# File 'lib/eye/child_process.rb', line 28 def pid @pid end |
#watchers ⇒ Object (readonly)
Returns the value of attribute watchers.
28 29 30 |
# File 'lib/eye/child_process.rb', line 28 def watchers @watchers end |
Instance Method Details
#delete ⇒ Object
83 84 |
# File 'lib/eye/child_process.rb', line 83 def delete end |
#destroy ⇒ Object
86 87 88 89 |
# File 'lib/eye/child_process.rb', line 86 def destroy remove_watchers terminate end |
#logger_tag ⇒ Object
46 47 48 |
# File 'lib/eye/child_process.rb', line 46 def logger_tag full_name end |
#monitor ⇒ Object
77 78 |
# File 'lib/eye/child_process.rb', line 77 def monitor end |
#prepare_command(command) ⇒ Object
override
99 100 101 |
# File 'lib/eye/child_process.rb', line 99 def prepare_command(command) # override super.gsub('{PARENT_PID}', @parent.pid.to_s) end |
#restart ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/eye/child_process.rb', line 69 def restart if self[:restart_command] execute_restart_command else stop end end |
#send_command(command, *args) ⇒ Object
58 59 60 |
# File 'lib/eye/child_process.rb', line 58 def send_command(command, *args) schedule command, *args, Eye::Reason::User.new(command) end |
#signal(sig) ⇒ Object
91 92 93 |
# File 'lib/eye/child_process.rb', line 91 def signal(sig) send_signal(sig) if pid end |
#start ⇒ Object
62 63 |
# File 'lib/eye/child_process.rb', line 62 def start end |
#state ⇒ Object
50 51 52 |
# File 'lib/eye/child_process.rb', line 50 def state :up end |
#status_data(opts = {}) ⇒ Object
95 96 97 |
# File 'lib/eye/child_process.rb', line 95 def status_data(opts = {}) self_status_data(opts) end |
#stop ⇒ Object
65 66 67 |
# File 'lib/eye/child_process.rb', line 65 def stop kill_process end |
#unmonitor ⇒ Object
80 81 |
# File 'lib/eye/child_process.rb', line 80 def unmonitor end |
#up? ⇒ Boolean
54 55 56 |
# File 'lib/eye/child_process.rb', line 54 def up? state == :up end |