Skip to content

Commit

Permalink
Force a worker check after a worker boots, don't wait 5sec. Fixes #574
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Sep 5, 2014
1 parent d33ae0f commit 3cbe521
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/puma/cluster.rb
Expand Up @@ -125,8 +125,8 @@ def all_workers_booted?
@workers.count { |w| !w.booted? } == 0
end

def check_workers
return if @next_check && @next_check >= Time.now
def check_workers(force=false)
return if !force && @next_check && @next_check >= Time.now

@next_check = Time.now + 5

Expand Down Expand Up @@ -357,6 +357,8 @@ def run
begin
res = IO.select([read], nil, nil, 5)

force_check = false

if res
req = read.read_nonblock(1)

Expand All @@ -369,6 +371,7 @@ def run
when "b"
w.boot!
log "- Worker #{w.index} (pid: #{pid}) booted, phase: #{w.phase}"
force_check = true
when "p"
w.ping!
end
Expand All @@ -382,7 +385,7 @@ def run
@phased_restart = false
end

check_workers
check_workers force_check

rescue Interrupt
@status = :stop
Expand Down

0 comments on commit 3cbe521

Please sign in to comment.