mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
parent
1df31245ca
commit
2f90396c95
5 changed files with 24 additions and 18 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
* Bugfixes
|
||||
* Cleanup daemonization in rc.d script (#2409)
|
||||
* Fire `on_booted` after server starts
|
||||
|
||||
* Refactor
|
||||
* Extract req/resp methods to new request.rb from server.rb (#2419)
|
||||
|
|
|
@ -395,9 +395,9 @@ module Puma
|
|||
stop
|
||||
end
|
||||
|
||||
@launcher.events.fire_on_booted!
|
||||
|
||||
begin
|
||||
booted = false
|
||||
|
||||
while @status == :run
|
||||
begin
|
||||
if @phased_restart
|
||||
|
@ -438,6 +438,10 @@ module Puma
|
|||
when "p"
|
||||
w.ping!(result.sub(/^\d+/,'').chomp)
|
||||
@launcher.events.fire(:ping!, w)
|
||||
if !booted && @workers.none? {|worker| worker.last_status.empty?}
|
||||
@launcher.events.fire_on_booted!
|
||||
booted = true
|
||||
end
|
||||
end
|
||||
else
|
||||
log "! Out-of-sync worker list, no #{pid} worker"
|
||||
|
|
|
@ -103,23 +103,25 @@ module Puma
|
|||
return
|
||||
end
|
||||
|
||||
Thread.new(@worker_write) do |io|
|
||||
Puma.set_thread_name "stat payload"
|
||||
while restart_server.pop
|
||||
server_thread = server.run
|
||||
stat_thread ||= Thread.new(@worker_write) do |io|
|
||||
Puma.set_thread_name "stat payload"
|
||||
|
||||
while true
|
||||
sleep Const::WORKER_CHECK_INTERVAL
|
||||
begin
|
||||
require 'json'
|
||||
io << "p#{Process.pid}#{server.stats.to_json}\n"
|
||||
rescue IOError
|
||||
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
|
||||
break
|
||||
while true
|
||||
begin
|
||||
require 'json'
|
||||
io << "p#{Process.pid}#{server.stats.to_json}\n"
|
||||
rescue IOError
|
||||
Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
|
||||
break
|
||||
end
|
||||
sleep Const::WORKER_CHECK_INTERVAL
|
||||
end
|
||||
end
|
||||
server_thread.join
|
||||
end
|
||||
|
||||
server.run.join while restart_server.pop
|
||||
|
||||
# Invoke any worker shutdown hooks so they can prevent the worker
|
||||
# exiting until any background operations are completed
|
||||
@launcher.config.run_hooks :before_worker_shutdown, index, @launcher.events
|
||||
|
|
|
@ -55,10 +55,11 @@ module Puma
|
|||
log "Use Ctrl-C to stop"
|
||||
redirect_io
|
||||
|
||||
server_thread = server.run
|
||||
@launcher.events.fire_on_booted!
|
||||
|
||||
begin
|
||||
server.run.join
|
||||
server_thread.join
|
||||
rescue Interrupt
|
||||
# Swallow it
|
||||
end
|
||||
|
|
|
@ -133,8 +133,6 @@ class TestCLI < Minitest::Test
|
|||
|
||||
assert_equal 2, status["workers"]
|
||||
|
||||
# wait until the first status ping has come through
|
||||
sleep 6
|
||||
s = UNIXSocket.new @tmp_path
|
||||
s << "GET /stats HTTP/1.0\r\n\r\n"
|
||||
body = s.read
|
||||
|
@ -144,6 +142,7 @@ class TestCLI < Minitest::Test
|
|||
ensure
|
||||
if UNIX_SKT_EXIST && HAS_FORK
|
||||
cli.launcher.stop
|
||||
t.join
|
||||
|
||||
done = nil
|
||||
until done
|
||||
|
@ -152,7 +151,6 @@ class TestCLI < Minitest::Test
|
|||
done = log[/ - Goodbye!/]
|
||||
end
|
||||
|
||||
t.join
|
||||
$debugging_hold = false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue