diff --git a/.travis.yml b/.travis.yml index c337671e34..dfda96fd61 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/lib/puma/dsl.rb b/lib/puma/dsl.rb index 64da03aa86..318bce80ff 100644 --- a/lib/puma/dsl.rb +++ b/lib/puma/dsl.rb @@ -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 @@ -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 diff --git a/test/config/with_integer_convert.rb b/test/config/with_integer_convert.rb new file mode 100644 index 0000000000..2ad83bc1f7 --- /dev/null +++ b/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" diff --git a/test/test_config.rb b/test/test_config.rb index b62a21817c..94fc525622 100644 --- a/test/test_config.rb +++ b/test/test_config.rb @@ -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 @@ -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