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

cluster: add worker_boot_timeout option

When your workers are loading, the normal operation timeout is in
effect. If you spawn many workers or have them perform a lot of work
or wait for just long enough before actually booting, they will be
killed by the worker ping timeout.

If you want to control the exact timeout for your workers to boot,
specify the `worker_boot_timeout` option. Otherwise, it defaults to
the value of the `worker_timeout` option.
This commit is contained in:
Alejandro Martinez Ruiz 2015-11-06 17:46:48 +01:00
parent 1cd87a600f
commit a01419c9c1
4 changed files with 13 additions and 0 deletions

View file

@ -149,6 +149,12 @@
#
# worker_timeout 60
# Change the default worker timeout for booting
#
# If unspecified, this defaults to the value of worker_timeout.
#
# worker_boot_timeout 60
# === Puma control rack application ===
# Start the puma control rack application on "url". This application can

View file

@ -136,6 +136,7 @@ module Puma
any = false
@workers.each do |w|
next if !w.booted? && !w.ping_timeout?(@options[:worker_boot_timeout])
if w.ping_timeout?(@options[:worker_timeout])
log "! Terminating timed out worker: #{w.pid}"
w.kill

View file

@ -27,6 +27,7 @@ module Puma
@conf[:before_worker_fork] ||= []
@conf[:after_worker_boot] ||= []
@conf[:worker_timeout] ||= DefaultWorkerTimeout
@conf[:worker_boot_timeout] ||= @conf[:worker_timeout]
@conf[:worker_shutdown_timeout] ||= DefaultWorkerShutdownTimeout
@options = {}

View file

@ -261,6 +261,11 @@ module Puma
@options[:worker_timeout] = timeout
end
# *Cluster mode only* Set the timeout for workers to boot
def worker_boot_timeout(timeout)
@options[:worker_boot_timeout] = timeout
end
# *Cluster mode only* Set the timeout for worker shutdown
def worker_shutdown_timeout(timeout)
@options[:worker_shutdown_timeout] = timeout