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