Skip to content

Commit

Permalink
Fix force kill under 1.9 and name version [macournoyer#92 state:resol…
Browse files Browse the repository at this point in the history
…ved]
  • Loading branch information
macournoyer committed May 21, 2009
1 parent 95a060a commit b1908c0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
== ? release
== 1.2.2 I Find Your Lack of Sauce Disturbing release
* Fix force kill under 1.9 [Alexey Chebotar]
* Fix regression when --only option is used w/ --socket.
* Add process name 'tag' functionality. Easier to distinguish thin daemons
from eachother in process listing [ctcherry]
Expand Down
23 changes: 17 additions & 6 deletions lib/thin/daemonizing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,14 @@ def restart(pid_file)

# Send a +signal+ to the process which PID is stored in +pid_file+.
def send_signal(signal, pid_file, timeout=60)
if File.file?(pid_file) && pid = File.read(pid_file)
pid = pid.to_i
if pid = read_pid_file(pid_file)
Logging.log "Sending #{signal} signal to process #{pid} ... "
Process.kill(signal, pid)
Timeout.timeout(timeout) do
sleep 0.1 while Process.running?(pid)
end
Logging.log ""
else
puts "Can't stop process, no PID found in #{pid_file}"
Logging.log "Can't stop process, no PID found in #{pid_file}"
end
rescue Timeout::Error
Logging.log "Timeout!"
Expand All @@ -130,8 +128,21 @@ def send_signal(signal, pid_file, timeout=60)
end

def force_kill(pid_file)
Process.kill("KILL", File.read(pid_file)) rescue nil
File.delete(pid_file) if File.exist?(pid_file) rescue nil
if pid = read_pid_file(pid_file)
Logging.log "Sending KILL signal to process #{pid} ... "
Process.kill("KILL", pid)
File.delete(pid_file) if File.exist?(pid_file)
else
Logging.log "Can't stop process, no PID found in #{pid_file}"
end
end

def read_pid_file(file)
if File.file?(file) && pid = File.read(file)
pid.to_i
else
nil
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/thin/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class PlatformNotSupported < RuntimeError; end
module VERSION #:nodoc:
MAJOR = 1
MINOR = 2
TINY = 1
TINY = 2

STRING = [MAJOR, MINOR, TINY].join('.')

CODENAME = "Asynctilicious Ultra Supreme".freeze
CODENAME = "I Find Your Lack of Sauce Disturbing".freeze

RACK = [1, 0].freeze # Rack protocol version
end
Expand Down

0 comments on commit b1908c0

Please sign in to comment.