Permalink
Browse files

only do a Conn#close on SIGTERM ~ graceful shutdown

  • Loading branch information...
1 parent af1a2f0 commit 520a10a654c7b3d7ff82b26b4229a15b871c313d @martinrehfeld committed Mar 5, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/rack/handler/mongrel2.rb
@@ -14,10 +14,12 @@ def self.run(app, options = {})
conn = ::Mongrel2::Connection.new(options)
running = true
+ graceful_shutdown = false
%w(INT TERM KILL).each do | sig |
Signal.trap(sig) do
running = false
+ graceful_shutdown = (sig == 'TERM')
end
end
@@ -59,7 +61,7 @@ def self.run(app, options = {})
exit
return
ensure
- conn.close
+ conn.close if graceful_shutdown
end
end #def self.run

0 comments on commit 520a10a

Please sign in to comment.