Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
only do a Conn#close on SIGTERM ~ graceful shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Rehfeld committed Mar 5, 2012
1 parent af1a2f0 commit 520a10a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rack/handler/mongrel2.rb
Expand Up @@ -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

Expand Down Expand Up @@ -59,7 +61,7 @@ def self.run(app, options = {})
exit
return
ensure
conn.close
conn.close if graceful_shutdown
end
end #def self.run

Expand Down

0 comments on commit 520a10a

Please sign in to comment.