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