Class: Eye::ChildProcess

Inherits:
Object show all
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

Process::Notify::LEVELS

Constants included from Process::Config

Process::Config::DEFAULTS

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#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

#configObject (readonly)

Returns the value of attribute config.



28
29
30
# File 'lib/eye/child_process.rb', line 28

def config
  @config
end

#full_nameObject (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

#nameObject (readonly)

Returns the value of attribute name.



28
29
30
# File 'lib/eye/child_process.rb', line 28

def name
  @name
end

#pidObject (readonly)

Returns the value of attribute pid.



28
29
30
# File 'lib/eye/child_process.rb', line 28

def pid
  @pid
end

#watchersObject (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

#deleteObject



78
# File 'lib/eye/child_process.rb', line 78

def delete; end

#destroyObject



80
81
82
83
# File 'lib/eye/child_process.rb', line 80

def destroy
  remove_watchers
  terminate
end

#logger_tagObject



48
49
50
# File 'lib/eye/child_process.rb', line 48

def logger_tag
  full_name
end

#monitorObject



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

#restartObject



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

#startObject



60
# File 'lib/eye/child_process.rb', line 60

def start; end

#stateObject



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

#stopObject



62
63
64
# File 'lib/eye/child_process.rb', line 62

def stop
  kill_process
end

#unmonitorObject



76
# File 'lib/eye/child_process.rb', line 76

def unmonitor; end

#up?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/eye/child_process.rb', line 56

def up?
  state == :up
end