mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
howbout we support asynchronous and synchronous stopping
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@687 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
parent
a511323f71
commit
9b23459be9
3 changed files with 14 additions and 11 deletions
|
@ -809,8 +809,13 @@ module Mongrel
|
|||
|
||||
# Stops the acceptor thread and then causes the worker threads to finish
|
||||
# off the request queue before finally exiting.
|
||||
def stop
|
||||
@acceptor.raise(StopServer.new)
|
||||
def stop(asynchronous=true)
|
||||
if asynchronous
|
||||
stopper = Thread.new { @acceptor.raise(StopServer.new) }
|
||||
stopper.priority = 10
|
||||
else
|
||||
@acceptor.raise(StopServer.new)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -287,14 +287,10 @@ module Mongrel
|
|||
# Calls .stop on all the configured listeners so they
|
||||
# stop processing requests (gracefully). By default it
|
||||
# assumes that you don't want to restart.
|
||||
def stop(needs_restart=false)
|
||||
@listeners.map do |name, listener|
|
||||
stopper = Thread.new { listener.stop }
|
||||
stopper.priority = 10
|
||||
stopper
|
||||
end.each do |stopper|
|
||||
stopper.join
|
||||
end
|
||||
def stop(needs_restart=false, asynchronous=true)
|
||||
@listeners.each {|name,s|
|
||||
s.stop(asynchronous)
|
||||
}
|
||||
|
||||
@needs_restart = needs_restart
|
||||
end
|
||||
|
@ -373,6 +369,8 @@ module Mongrel
|
|||
if RUBY_PLATFORM !~ /mswin/
|
||||
# graceful shutdown
|
||||
trap("TERM") { log "TERM signal received."; stop }
|
||||
trap("USR1") { log "USR1 received, toggling $mongrel_debug_client to #{!$mongrel_debug_client}"; $mongrel_debug_client = !$mongrel_debug_client }
|
||||
# restart
|
||||
trap("USR2") { log "USR2 signal received."; stop(true) }
|
||||
|
||||
log "Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart)."
|
||||
|
|
|
@ -78,7 +78,7 @@ class ConfiguratorTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
redirect_test_io do
|
||||
config.stop
|
||||
config.stop(false, true)
|
||||
end
|
||||
|
||||
assert_raise Errno::EBADF, Errno::ECONNREFUSED do
|
||||
|
|
Loading…
Add table
Reference in a new issue