1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

make phased restarts faster

Have the worker send the master "tPID" immediately before shutdown; this
lets the master move on to booting the next worker immediately, instead
of waiting for the next iteration of the select() loop.
This commit is contained in:
Ben Osheroff 2016-01-14 17:01:35 -08:00
parent 246e71840e
commit 3fdf0c9681

View file

@ -65,6 +65,14 @@ module Puma
@stage = :booted
end
def dead?
@dead
end
def dead!
@dead = true
end
def ping!
@last_checkin = Time.now
end
@ -128,7 +136,7 @@ module Puma
@workers.count { |w| !w.booted? } == 0
end
def check_workers(force=false)
def check_workers(force)
return if !force && @next_check && @next_check >= Time.now
@next_check = Time.now + 5
@ -155,6 +163,8 @@ module Puma
@workers.delete_if { |w| w.pid == pid }
end
@workers.delete_if(&:dead?)
spawn_workers
if all_workers_booted?
@ -242,6 +252,7 @@ module Puma
hooks = @options[:before_worker_shutdown]
hooks.each { |h| h.call(index) }
ensure
@worker_write << "t#{Process.pid}\n" rescue nil
@worker_write.close
end
@ -412,6 +423,9 @@ module Puma
w.boot!
log "- Worker #{w.index} (pid: #{pid}) booted, phase: #{w.phase}"
force_check = true
when "t"
w.dead!
force_check = true
when "p"
w.ping!
end