def stop(no_wait = false)
unless running?
zap
return
end
pid = @pid.pid
begin
Process.kill(SIGNAL, pid)
rescue Errno::ESRCH => e
@report.output_message("#{e} #{pid}")
@report.output_message('deleting pid-file.')
end
unless no_wait
if @force_kill_waittime > 0
@report.stopping_process(group.app_name, pid)
$stdout.flush
begin
Timeout.timeout(@force_kill_waittime, TimeoutError) do
while Pid.running?(pid)
sleep(0.2)
end
end
rescue TimeoutError
@report.forcefully_stopping_process(group.app_name, pid)
$stdout.flush
begin
Process.kill('KILL', pid)
rescue Errno::ESRCH
end
begin
Timeout.timeout(20, TimeoutError) do
while Pid.running?(pid)
sleep(1)
end
end
rescue TimeoutError
@report.cannot_stop_process(group.app_name, pid)
$stdout.flush
end
end
end
end
sleep(0.1)
unless Pid.running?(pid)
zap!
@report.stopped_process(group.app_name, pid)
$stdout.flush
end
end