Module: Eye::Process::Controller
- Included in:
- Eye::Process
- Defined in:
- lib/eye/process/controller.rb
Instance Method Summary collapse
- #delete ⇒ Object
- #monitor ⇒ Object
- #restart ⇒ Object
- #send_command(command, *args) ⇒ Object
- #signal(sig = 0) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #unmonitor ⇒ Object
Instance Method Details
#delete ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/eye/process/controller.rb', line 56 def delete if self[:stop_on_delete] info 'process has stop_on_delete option, so sync-stop it first' stop end remove_watchers remove_children remove_triggers terminate end |
#monitor ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/eye/process/controller.rb', line 38 def monitor if self[:auto_start] start else if try_update_pid_from_file info "process <#{self.pid}> from pid_file is already running" switch :already_running else warn 'process not found, unmonitoring' schedule :unmonitor, Eye::Reason.new(:'not found') end end end |
#restart ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/eye/process/controller.rb', line 30 def restart unless pid # unmonitored case try_update_pid_from_file end restart_process end |
#send_command(command, *args) ⇒ Object
3 4 5 |
# File 'lib/eye/process/controller.rb', line 3 def send_command(command, *args) schedule command, *args, Eye::Reason::User.new(command) end |
#signal(sig = 0) ⇒ Object
69 70 71 |
# File 'lib/eye/process/controller.rb', line 69 def signal(sig = 0) send_signal(sig) if self.pid end |
#start ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/eye/process/controller.rb', line 7 def start res = if set_pid_from_file if process_really_running? info "process <#{self.pid}> from pid_file is already running" switch :already_running :ok else info "pid_file found, but process <#{self.pid}> is down, starting..." start_process end else info 'pid_file not found, starting...' start_process end res end |
#stop ⇒ Object
25 26 27 28 |
# File 'lib/eye/process/controller.rb', line 25 def stop stop_process switch :unmonitoring end |
#unmonitor ⇒ Object
52 53 54 |
# File 'lib/eye/process/controller.rb', line 52 def unmonitor switch :unmonitoring end |