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

Look to use if user is pruning bundler. update cli tests.

This commit is contained in:
Jeff Levin 2020-04-12 22:37:02 -08:00
parent ebc1422cb9
commit d8b72e84f5
4 changed files with 19 additions and 10 deletions

View file

@ -10,8 +10,8 @@
* Changed #connected_port to #connected_ports (#2076)
* `--control` has been removed. Use `--control-url` (#1487)
* `worker_directory` has been removed. Use `directory`
* min_threads now set by environment variables RAILS_MIN_THREADS and MIN_THREADS
* max_threads now set by environment variables RAILS_MAX_THREADS and MAX_THREADS
* min_threads now set by environment variables PUMA_MIN_THREADS and MIN_THREADS
* max_threads now set by environment variables PUMA_MAX_THREADS and MAX_THREADS
* max_threads default to 5 in MRI or 16 for all other interpretters
* preload by default if workers > 1 and interpretter supports workers

View file

@ -137,7 +137,13 @@ module Puma
@file_dsl = DSL.new(@options.file_options, self)
@default_dsl = DSL.new(@options.default_options, self)
default_options[:preload_app] = (default_options[:workers] > 1 && Puma::Plugin.new.workers_supported?)
# 1. workers_supported - #Puma::Plugin.new.workers_supported?)
workers_supported = !(Puma.jruby? || Puma.windows?)
# 2. preload app
if !@options[:prune_bundler]
default_options[:preload_app] =(@options[:workers] > 1) && workers_supported
end
if block
configure(&block)
@ -176,8 +182,8 @@ module Puma
def puma_default_options
{
:min_threads => Integer(ENV['RAILS_MIN_THREADS'] || ENV['MIN_THREADS'] || 0),
:max_threads => Integer(ENV['RAILS_MAX_THREADS'] || ENV['MAX_THREADS'] || default_max_threads),
:min_threads => Integer(ENV['PUMA_MIN_THREADS'] || ENV['MIN_THREADS'] || 0),
:max_threads => Integer(ENV['PUMA_MAX_THREADS'] || ENV['MAX_THREADS'] || default_max_threads),
:log_requests => false,
:debug => false,
:binds => ["tcp://#{DefaultTCPHost}:#{DefaultTCPPort}"],

View file

@ -55,7 +55,8 @@ class TestCLI < Minitest::Test
body = s.read
s.close
assert_match(/{"started_at":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z","backlog":0,"running":0,"pool_capacity":16,"max_threads":16,"requests_count":0}/, body.split(/\r?\n/).last)
dmt = Puma::Configuration.new.default_max_threads
assert_match(/{"started_at":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z","backlog":0,"running":0,"pool_capacity":#{dmt},"max_threads":#{dmt},"requests_count":0}/, body.split(/\r?\n/).last)
ensure
cli.launcher.stop
@ -87,7 +88,8 @@ class TestCLI < Minitest::Test
body = http.request(req).body
end
expected_stats = /{"started_at":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z","backlog":0,"running":0,"pool_capacity":16,"max_threads":16,"requests_count":0}/
dmt = Puma::Configuration.new.default_max_threads
expected_stats = /{"started_at":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z","backlog":0,"running":0,"pool_capacity":#{dmt},"max_threads":#{dmt}/
assert_match(expected_stats, body.split(/\r?\n/).last)
assert_equal([:started_at, :backlog, :running, :pool_capacity, :max_threads, :requests_count], Puma.stats.keys)
@ -167,7 +169,8 @@ class TestCLI < Minitest::Test
body = s.read
s.close
assert_match(/{"started_at":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z","backlog":0,"running":0,"pool_capacity":16,"max_threads":16,"requests_count":0}/, body.split("\r\n").last)
dmt = Puma::Configuration.new.default_max_threads
assert_match(/{"started_at":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z","backlog":0,"running":0,"pool_capacity":#{dmt},"max_threads":#{dmt},"requests_count":0}/, body.split("\r\n").last)
ensure
if UNIX_SKT_EXIST
cli.launcher.stop

View file

@ -22,7 +22,7 @@ class TestConfigFile < TestConfigFileBase
conf = Puma::Configuration.new
assert_equal 7, conf.options.default_options[:min_threads]
ENV['RAILS_MIN_THREADS'] = '8'
ENV['PUMA_MIN_THREADS'] = '8'
conf = Puma::Configuration.new
assert_equal 8, conf.options.default_options[:min_threads]
end
@ -35,7 +35,7 @@ class TestConfigFile < TestConfigFileBase
conf = Puma::Configuration.new
assert_equal 7, conf.options.default_options[:max_threads]
ENV['RAILS_MAX_THREADS'] = '8'
ENV['PUMA_MAX_THREADS'] = '8'
conf = Puma::Configuration.new
assert_equal 8, conf.options.default_options[:max_threads]
end