Permalink
Browse files

Fix force kill under 1.9 and name version [#92 state:resolved]

  • Loading branch information...
1 parent 95a060a commit b1908c0c38e4b7b253975492abc463cddf631dde @macournoyer macournoyer committed May 21, 2009
Showing with 21 additions and 9 deletions.
  1. +2 −1 CHANGELOG
  2. +17 −6 lib/thin/daemonizing.rb
  3. +2 −2 lib/thin/version.rb
View
@@ -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]
View
@@ -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!"
@@ -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
View
@@ -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

0 comments on commit b1908c0

Please sign in to comment.