Module: Thin::Daemonizable::ClassMethods
- Defined in:
- lib/thin/daemonizing.rb
Instance Method Summary collapse
-
#kill(pid_file, timeout = 60) ⇒ Object
Kill the process which PID is stored in
pid_file
.
Instance Method Details
#kill(pid_file, timeout = 60) ⇒ Object
Kill the process which PID is stored in pid_file
.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/thin/daemonizing.rb', line 86 def kill(pid_file, timeout=60) if File.exist?(pid_file) && pid = open(pid_file).read pid = pid.to_i print "Sending INT signal to process #{pid} ... " begin Process.kill('INT', pid) Timeout.timeout(timeout) do sleep 0.1 while Process.running?(pid) end rescue Timeout::Error print "timeout, Sending KILL signal ... " Process.kill('KILL', pid) end puts "stopped!" else puts "Can't stop process, no PID found in #{@pid_file}" end rescue Errno::ESRCH # No such process puts "process not found!" ensure File.delete(pid_file) rescue nil end |