# File lib/thin/daemonizing.rb, line 133 133: def force_kill(pid_file) 134: if pid = read_pid_file(pid_file) 135: Logging.log "Sending KILL signal to process #{pid} ... " 136: Process.kill("KILL", pid) 137: File.delete(pid_file) if File.exist?(pid_file) 138: else 139: Logging.log "Can't stop process, no PID found in #{pid_file}" 140: end 141: end
Send a QUIT or INT (if timeout is 0) signal the process which PID is stored in pid_file. If the process is still running after timeout, KILL signal is sent.
# File lib/thin/daemonizing.rb, line 99 99: def kill(pid_file, timeout=60) 100: if timeout == 0 101: send_signal('INT', pid_file, timeout) 102: else 103: send_signal('QUIT', pid_file, timeout) 104: end 105: end
# File lib/thin/daemonizing.rb, line 143 143: def read_pid_file(file) 144: if File.file?(file) && pid = File.read(file) 145: pid.to_i 146: else 147: nil 148: end 149: end
Restart the server by sending HUP signal.
# File lib/thin/daemonizing.rb, line 108 108: def restart(pid_file) 109: send_signal('HUP', pid_file) 110: end
Send a signal to the process which PID is stored in pid_file.
# File lib/thin/daemonizing.rb, line 113 113: def send_signal(signal, pid_file, timeout=60) 114: if pid = read_pid_file(pid_file) 115: Logging.log "Sending #{signal} signal to process #{pid} ... " 116: Process.kill(signal, pid) 117: Timeout.timeout(timeout) do 118: sleep 0.1 while Process.running?(pid) 119: end 120: else 121: Logging.log "Can't stop process, no PID found in #{pid_file}" 122: end 123: rescue Timeout::Error 124: Logging.log "Timeout!" 125: force_kill pid_file 126: rescue Interrupt 127: force_kill pid_file 128: rescue Errno::ESRCH # No such process 129: Logging.log "process not found!" 130: force_kill pid_file 131: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.