Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worker_timeout, worker_boot_timeout, worker_shutdown_timeout fix integer convert #1450

Merged
merged 5 commits into from Mar 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -6,7 +6,7 @@ cache: bundler
before_install:
# bundler installation needed for jruby-head
# https://github.com/travis-ci/travis-ci/issues/5861
- gem install bundler
- gem update --system
branches:
only:
- "master"
Expand Down
10 changes: 5 additions & 5 deletions lib/puma/dsl.rb
Expand Up @@ -146,13 +146,13 @@ def port(port, host=nil)
# them
#
def persistent_timeout(seconds)
@options[:persistent_timeout] = seconds
@options[:persistent_timeout] = Integer(seconds)
end

# Define how long the tcp socket stays open, if no data has been received
#
def first_data_timeout(seconds)
@options[:first_data_timeout] = seconds
@options[:first_data_timeout] = Integer(seconds)
end

# Work around leaky apps that leave garbage in Thread locals
Expand Down Expand Up @@ -424,17 +424,17 @@ def tag(string)
# that have not checked in within the given +timeout+.
# This mitigates hung processes. Default value is 60 seconds.
def worker_timeout(timeout)
@options[:worker_timeout] = timeout
@options[:worker_timeout] = Integer(timeout)
end

# *Cluster mode only* Set the timeout for workers to boot
def worker_boot_timeout(timeout)
@options[:worker_boot_timeout] = timeout
@options[:worker_boot_timeout] = Integer(timeout)
end

# *Cluster mode only* Set the timeout for worker shutdown
def worker_shutdown_timeout(timeout)
@options[:worker_shutdown_timeout] = timeout
@options[:worker_shutdown_timeout] = Integer(timeout)
end

# When set to true (the default), workers accept all requests
Expand Down
9 changes: 9 additions & 0 deletions test/config/with_integer_convert.rb
@@ -0,0 +1,9 @@
persistent_timeout "6"
first_data_timeout "3"

workers "2"
threads "4", "8"

worker_timeout "90"
worker_boot_timeout "120"
worker_shutdown_timeout "150"
17 changes: 16 additions & 1 deletion test/test_config.rb
Expand Up @@ -43,7 +43,7 @@ def test_double_bind_port
end
end

def test_lowleve_error_handler_DSL
def test_lowlevel_error_handler_DSL
conf = Puma::Configuration.new do |c|
c.load "test/config/app.rb"
end
Expand Down Expand Up @@ -135,6 +135,21 @@ def test_config_files_with_specified_environment
assert_equal ['config/puma/fake-env.rb'], conf.config_files
end

def test_config_files_with_integer_convert
conf = Puma::Configuration.new(config_files: ['test/config/with_integer_convert.rb']) do
end
conf.load

assert_equal 6, conf.options[:persistent_timeout]
assert_equal 3, conf.options[:first_data_timeout]
assert_equal 2, conf.options[:workers]
assert_equal 4, conf.options[:min_threads]
assert_equal 8, conf.options[:max_threads]
assert_equal 90, conf.options[:worker_timeout]
assert_equal 120, conf.options[:worker_boot_timeout]
assert_equal 150, conf.options[:worker_shutdown_timeout]
end

def teardown
FileUtils.rm_r("config/puma")
end
Expand Down