mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Merge pull request #1751 from puma/f-move-const
Move WORKER_CHECK_INTERVAL const. Fixes #1731
This commit is contained in:
commit
d018c75c44
3 changed files with 10 additions and 6 deletions
|
@ -19,8 +19,6 @@ module Puma
|
|||
# via the `spawn_workers` method call. Each worker will have it's own
|
||||
# instance of a `Puma::Server`.
|
||||
class Cluster < Runner
|
||||
WORKER_CHECK_INTERVAL = 5
|
||||
|
||||
def initialize(cli, events)
|
||||
super cli, events
|
||||
|
||||
|
@ -201,7 +199,7 @@ module Puma
|
|||
def check_workers(force=false)
|
||||
return if !force && @next_check && @next_check >= Time.now
|
||||
|
||||
@next_check = Time.now + WORKER_CHECK_INTERVAL
|
||||
@next_check = Time.now + Const::WORKER_CHECK_INTERVAL
|
||||
|
||||
any = false
|
||||
|
||||
|
@ -308,7 +306,7 @@ module Puma
|
|||
base_payload = "p#{Process.pid}"
|
||||
|
||||
while true
|
||||
sleep WORKER_CHECK_INTERVAL
|
||||
sleep Const::WORKER_CHECK_INTERVAL
|
||||
begin
|
||||
b = server.backlog || 0
|
||||
r = server.running || 0
|
||||
|
@ -506,7 +504,7 @@ module Puma
|
|||
|
||||
force_check = false
|
||||
|
||||
res = IO.select([read], nil, nil, WORKER_CHECK_INTERVAL)
|
||||
res = IO.select([read], nil, nil, Const::WORKER_CHECK_INTERVAL)
|
||||
|
||||
if res
|
||||
req = read.read_nonblock(1)
|
||||
|
|
|
@ -227,5 +227,9 @@ module Puma
|
|||
HIJACK_IO = "rack.hijack_io".freeze
|
||||
|
||||
EARLY_HINTS = "rack.early_hints".freeze
|
||||
|
||||
# Mininum interval to checks worker health
|
||||
WORKER_CHECK_INTERVAL = 5
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'puma/const'
|
||||
|
||||
module Puma
|
||||
# The methods that are available for use inside the config file.
|
||||
# These same methods are used in Puma cli and the rack handler
|
||||
|
@ -463,7 +465,7 @@ module Puma
|
|||
# This mitigates hung processes. Default value is 60 seconds.
|
||||
def worker_timeout(timeout)
|
||||
timeout = Integer(timeout)
|
||||
min = Cluster::WORKER_CHECK_INTERVAL
|
||||
min = Const::WORKER_CHECK_INTERVAL
|
||||
|
||||
if timeout <= min
|
||||
raise "The minimum worker_timeout must be greater than the worker reporting interval (#{min})"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue