3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/eye/process/commands.rb', line 3
def start_process
debug 'start_process command'
switch :starting
unless self[:start_command]
warn 'no :start_command found, unmonitoring'
switch :unmonitoring, Eye::Reason.new(:no_start_command)
return :no_start_command
end
result = self[:daemonize] ? daemonize_process : execute_process
if !result[:error]
debug "process <#{self.pid}> started successfully"
switch :started
else
error "process <#{self.pid}> failed to start (#{result[:error].inspect})"
if process_really_running?
warn "killing <#{self.pid}> due to error"
send_signal(:KILL)
sleep 0.2 end
self.pid = nil
switch :crashed
end
result
rescue StateMachine::InvalidTransition, Eye::Process::StateError => e
warn "wrong switch '#{e.message}'"
:state_error
end
|