def send_signal(signal, pid_file, timeout=60)
if pid = read_pid_file(pid_file)
Logging.log_info "Sending #{signal} signal to process #{pid} ... "
Process.kill(signal, pid)
Timeout.timeout(timeout) do
sleep 0.1 while Process.running?(pid)
end
else
raise PidFileNotFound, "Can't stop process, no PID found in #{pid_file}"
end
rescue Timeout::Error
Logging.log_info "Timeout!"
force_kill(pid, pid_file)
rescue Interrupt
force_kill(pid, pid_file)
rescue Errno::ESRCH
Logging.log_info "process not found!"
force_kill(pid, pid_file)
end