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.
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
- #signal(sig) ⇒ Object
- #start ⇒ Object
- #state ⇒ Object
- #status_data(opts = {}) ⇒ Object
- #stop ⇒ Object
- #unmonitor ⇒ Object
- #up? ⇒ Boolean
Methods included from Process::Scheduler
#ensure_scheduler_process, #equal_action_call?, #filter_call, #internal_schedule, #schedule, #scheduler_add, #scheduler_calls, #scheduler_clear_pending_list, #scheduler_commands_list, #scheduler_consume, #scheduler_current_command, #scheduler_history, #scheduler_last_command, #scheduler_last_reason, #scheduler_run, #send_call, #user_schedule
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?, #timers_data
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 45 46 |
# File 'lib/eye/child_process.rb', line 30 def initialize(pid, config = {}, logger_prefix = nil, parent = nil) raise 'Empty pid' unless pid @pid = pid @config = prepare_config(config) @name = "child-#{pid}" @full_name = [logger_prefix, @name].join(':') @watchers = {} @scheduler_history = parent.scheduler_history @parent_pid = parent.pid 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 |
#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
78 |
# File 'lib/eye/child_process.rb', line 78 def delete; end |
#destroy ⇒ Object
80 81 82 83 |
# File 'lib/eye/child_process.rb', line 80 def destroy remove_watchers terminate end |
#logger_tag ⇒ Object
48 49 50 |
# File 'lib/eye/child_process.rb', line 48 def logger_tag full_name end |
#monitor ⇒ Object
74 |
# File 'lib/eye/child_process.rb', line 74 def monitor; end |
#prepare_command(command) ⇒ Object
override
94 95 96 |
# File 'lib/eye/child_process.rb', line 94 def prepare_command(command) super.gsub('{PARENT_PID}', @parent_pid.to_s) end |
#restart ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/eye/child_process.rb', line 66 def restart if self[:restart_command] execute_restart_command else stop end end |
#signal(sig) ⇒ Object
85 86 87 |
# File 'lib/eye/child_process.rb', line 85 def signal(sig) send_signal(sig) if pid end |
#start ⇒ Object
60 |
# File 'lib/eye/child_process.rb', line 60 def start; end |
#state ⇒ Object
52 53 54 |
# File 'lib/eye/child_process.rb', line 52 def state :up end |
#status_data(opts = {}) ⇒ Object
89 90 91 |
# File 'lib/eye/child_process.rb', line 89 def status_data(opts = {}) self_status_data(opts) end |
#stop ⇒ Object
62 63 64 |
# File 'lib/eye/child_process.rb', line 62 def stop kill_process end |
#unmonitor ⇒ Object
76 |
# File 'lib/eye/child_process.rb', line 76 def unmonitor; end |
#up? ⇒ Boolean
56 57 58 |
# File 'lib/eye/child_process.rb', line 56 def up? state == :up end |