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:
parent
246e71840e
commit
3fdf0c9681
1 changed files with 15 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue