about summary refs log tree commit homepage
path: root/lib/unicorn.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-05-04 02:07:40 +0000
committerEric Wong <normalperson@yhbt.net>2009-05-03 21:22:48 -0700
commitc2e51916201f4f29a72e21320b38181ee1eaa697 (patch)
tree25cbe6fbfbcfff7f68c654873ea2c5ac422afd2d /lib/unicorn.rb
parenta7830cce6a3bf13996fe42503164437fb9809909 (diff)
downloadunicorn-c2e51916201f4f29a72e21320b38181ee1eaa697.tar.gz
Use SIGQUIT if you're going to be nice and do graceful
shutdowns.  Sometimes people run real applications on this
server and SIGINT/SIGTERM get lost/trapped when Object is
rescued and that is not good.  Also make sure we break out of
the loop properly when the master is dead.

Testcases added for both SIGINT and dead master handling.
Diffstat (limited to 'lib/unicorn.rb')
-rw-r--r--lib/unicorn.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index db25223..a539960 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -474,7 +474,7 @@ module Unicorn
       # closing anything we IO.select on will raise EBADF
       trap(:USR1) { nr = -65536; SELF_PIPE.first.close rescue nil }
       trap(:QUIT) { alive = nil; LISTENERS.each { |s| s.close rescue nil } }
-      [:TERM, :INT].each { |sig| trap(sig) { exit(0) } } # instant shutdown
+      [:TERM, :INT].each { |sig| trap(sig) { exit!(0) } } # instant shutdown
       @logger.info "worker=#{worker.nr} ready"
 
       while alive
@@ -512,7 +512,7 @@ module Unicorn
           # and do a speculative accept_nonblock on every listener
           # before we sleep again in select().
           if nr == 0 # (nr < 0) => reopen logs
-            master_pid == Process.ppid or exit(0)
+            master_pid == Process.ppid or return
             alive.chmod(nr += 1)
             begin
               # timeout used so we can detect parent death:
@@ -524,8 +524,6 @@ module Unicorn
               nr < 0 or exit(alive ? 1 : 0)
             end
           end
-        rescue SignalException, SystemExit => e
-          raise e
         rescue Object => e
           if alive
             logger.error "Unhandled listen loop exception #{e.inspect}."