mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Refactor listener closing code (#2112)
* Simplify Runner#start_control URL parsing Reuse logic from Binder#parse. * Parameterize log message * Ensure control server Unix socket is closed on shutdown Remove Binder#close_unix_paths Co-authored-by: Nate Berkopec <nate.berkopec@gmail.com>
This commit is contained in:
parent
522b8776c8
commit
964747031f
6 changed files with 20 additions and 8 deletions
|
@ -13,6 +13,7 @@
|
|||
|
||||
* Bugfixes
|
||||
* Windows update extconf.rb for use with ssp and varied Ruby/MSYS2 combinations (#2069)
|
||||
* Ensure control server Unix socket is closed on shutdown (#2112)
|
||||
* Preserve `BUNDLE_GEMFILE` env var when using `prune_bundler` (#1893)
|
||||
* Send 408 request timeout even when queue requests is disabled (#2119)
|
||||
* Rescue IO::WaitReadable instead of EAGAIN for blocking read (#2121)
|
||||
|
|
|
@ -370,10 +370,6 @@ module Puma
|
|||
end
|
||||
end
|
||||
|
||||
def close_unix_paths
|
||||
@unix_paths.each { |up| File.unlink(up) if File.exist? up }
|
||||
end
|
||||
|
||||
def redirects_for_restart
|
||||
redirects = {:close_others => true}
|
||||
@listeners.each_with_index do |(l, io), i|
|
||||
|
|
|
@ -184,7 +184,7 @@ module Puma
|
|||
when :exit
|
||||
# nothing
|
||||
end
|
||||
@binder.close_unix_paths
|
||||
close_binder_listeners unless @status == :restart
|
||||
end
|
||||
|
||||
# Return all tcp ports the launcher may be using, TCP or SSL
|
||||
|
@ -202,6 +202,7 @@ module Puma
|
|||
end
|
||||
|
||||
def close_binder_listeners
|
||||
@runner.close_control_listeners
|
||||
@binder.close_listeners
|
||||
end
|
||||
|
||||
|
|
|
@ -68,6 +68,10 @@ module Puma
|
|||
@control = control
|
||||
end
|
||||
|
||||
def close_control_listeners
|
||||
@control.binder.close_listeners if @control
|
||||
end
|
||||
|
||||
def ruby_engine
|
||||
if !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby"
|
||||
"ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
||||
|
|
|
@ -90,7 +90,7 @@ class TestBinder < TestBinderBase
|
|||
|
||||
refute_includes @binder.instance_variable_get(:@unix_paths), unix_path
|
||||
|
||||
@binder.close_unix_paths
|
||||
@binder.close_listeners
|
||||
|
||||
assert File.exist?(unix_path)
|
||||
|
||||
|
@ -150,7 +150,7 @@ class TestBinder < TestBinderBase
|
|||
assert stdout.include?(prepared_paths[order[0]]), "\n#{stdout}\n"
|
||||
assert stdout.include?(prepared_paths[order[1]]), "\n#{stdout}\n"
|
||||
ensure
|
||||
@binder.close_unix_paths if order.include?(:unix) && UNIX_SKT_EXIST
|
||||
@binder.close_listeners if order.include?(:unix) && UNIX_SKT_EXIST
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ class TestIntegrationPumactl < TestIntegration
|
|||
def teardown
|
||||
super
|
||||
|
||||
refute File.exist?(@control_path), "Control path must be removed after stop"
|
||||
ensure
|
||||
[@state_path, @control_path].each { |p| File.unlink(p) rescue nil }
|
||||
end
|
||||
|
||||
|
@ -30,10 +32,18 @@ class TestIntegrationPumactl < TestIntegration
|
|||
end
|
||||
|
||||
def test_stop_unix
|
||||
ctl_unix
|
||||
end
|
||||
|
||||
def test_halt_unix
|
||||
ctl_unix 'halt'
|
||||
end
|
||||
|
||||
def ctl_unix(signal='stop')
|
||||
skip UNIX_SKT_MSG unless UNIX_SKT_EXIST
|
||||
cli_server "-q test/rackup/sleep.ru --control-url unix://#{@control_path} --control-token #{TOKEN} -S #{@state_path}", unix: true
|
||||
|
||||
cli_pumactl "stop", unix: true
|
||||
cli_pumactl signal, unix: true
|
||||
|
||||
_, status = Process.wait2(@pid)
|
||||
assert_equal 0, status
|
||||
|
|
Loading…
Reference in a new issue