Module: Eye::Process::Controller

Included in:
Eye::Process
Defined in:
lib/eye/process/controller.rb

Instance Method Summary collapse

Instance Method Details

#deleteObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/eye/process/controller.rb', line 39

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

#monitorObject



25
26
27
28
29
30
31
32
33
# File 'lib/eye/process/controller.rb', line 25

def monitor
  if self[:auto_start]
    start
  elsif load_external_pid_file == :ok
    switch :already_running
  else
    schedule command: :unmonitor, reason: 'not found'
  end
end

#restartObject



20
21
22
23
# File 'lib/eye/process/controller.rb', line 20

def restart
  load_external_pid_file unless pid # unmonitored case
  restart_process
end

#signal(sig = 0) ⇒ Object



52
53
54
# File 'lib/eye/process/controller.rb', line 52

def signal(sig = 0)
  send_signal(sig) if self.pid
end

#startObject

scheduled actions :update_config, :start, :stop, :restart, :unmonitor, :monitor, :break_chain, :delete, :signal, :user_command



6
7
8
9
10
11
12
13
# File 'lib/eye/process/controller.rb', line 6

def start
  if load_external_pid_file == :ok
    switch :already_running
    :ok
  else
    start_process
  end
end

#stopObject



15
16
17
18
# File 'lib/eye/process/controller.rb', line 15

def stop
  stop_process
  switch :unmonitoring
end

#unmonitorObject



35
36
37
# File 'lib/eye/process/controller.rb', line 35

def unmonitor
  switch :unmonitoring
end

#user_command(name) ⇒ Object



56
57
58
59
60
# File 'lib/eye/process/controller.rb', line 56

def user_command(name)
  if self[:user_commands] && c = self[:user_commands][name.to_sym]
    execute_user_command(name, c)
  end
end