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