Method: Thin::Daemonizable::ClassMethods#send_signal
- Defined in:
- lib/thin/daemonizing.rb
#send_signal(signal, pid_file, timeout = 60) ⇒ Object
Send a signal to the process which PID is stored in pid_file.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/thin/daemonizing.rb', line 135 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) # This loop seems kind of racy to me... started_at = monotonic_time while Process.running?(pid) sleep 0.1 raise Timeout::Error if (monotonic_time - started_at) > timeout 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 # No such process Logging.log_info "process not found!" force_kill(pid, pid_file) end |