mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
ITS THE FINAL COUNTDOWWNNNNN.....(yeah, Ill rebase)
This commit is contained in:
parent
b2dad7b9f7
commit
e552e6ce65
2 changed files with 62 additions and 50 deletions
|
@ -137,10 +137,9 @@ module Puma
|
|||
@file_dsl = DSL.new(@options.file_options, self)
|
||||
@default_dsl = DSL.new(@options.default_options, self)
|
||||
|
||||
workers_supported = !(Puma.jruby? || Puma.windows?)
|
||||
|
||||
if !@options[:prune_bundler]
|
||||
default_options[:preload_app] = (@options[:workers] > 1) && workers_supported
|
||||
default_options[:preload_app] = (@options[:workers] > 1) && ::Process.respond_to?(:fork)
|
||||
end
|
||||
|
||||
if block
|
||||
|
@ -174,8 +173,7 @@ module Puma
|
|||
end
|
||||
|
||||
def default_max_threads
|
||||
return 5 if Puma.mri?
|
||||
16
|
||||
Puma.mri? ? 5 : 16
|
||||
end
|
||||
|
||||
def puma_default_options
|
||||
|
@ -186,7 +184,6 @@ module Puma
|
|||
:debug => false,
|
||||
:binds => ["tcp://#{DefaultTCPHost}:#{DefaultTCPPort}"],
|
||||
:workers => Integer(ENV['WEB_CONCURRENCY'] || 0),
|
||||
:daemon => false,
|
||||
:mode => :http,
|
||||
:worker_timeout => DefaultWorkerTimeout,
|
||||
:worker_boot_timeout => DefaultWorkerTimeout,
|
||||
|
|
|
@ -6,6 +6,7 @@ require_relative "helpers/config_file"
|
|||
require "puma/configuration"
|
||||
require 'puma/events'
|
||||
|
||||
|
||||
class TestConfigFile < TestConfigFileBase
|
||||
parallelize_me!
|
||||
|
||||
|
@ -15,51 +16,6 @@ class TestConfigFile < TestConfigFileBase
|
|||
assert_equal max_threads, Puma::Configuration.new.default_max_threads
|
||||
end
|
||||
|
||||
def test_config_loads_correct_min_threads
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 0, conf.options.default_options[:min_threads]
|
||||
|
||||
ENV['MIN_THREADS'] = '7'
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 7, conf.options.default_options[:min_threads]
|
||||
|
||||
ENV['PUMA_MIN_THREADS'] = '8'
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 8, conf.options.default_options[:min_threads]
|
||||
end
|
||||
|
||||
def test_config_loads_correct_max_threads
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal conf.default_max_threads, conf.options.default_options[:max_threads]
|
||||
|
||||
ENV['MAX_THREADS'] = '7'
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 7, conf.options.default_options[:max_threads]
|
||||
|
||||
ENV['PUMA_MAX_THREADS'] = '8'
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 8, conf.options.default_options[:max_threads]
|
||||
end
|
||||
|
||||
def test_config_loads_correct_workers
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 0, conf.options.default_options[:workers]
|
||||
|
||||
ENV['WEB_CONCURRENCY'] = '8'
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 8, conf.options.default_options[:workers]
|
||||
end
|
||||
|
||||
def test_config_preloads_app_if_using_workers
|
||||
ENV['WEB_CONCURRENCY'] = '0'
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal false, conf.options.default_options[:preload_app]
|
||||
|
||||
ENV['WEB_CONCURRENCY'] = '2'
|
||||
preload = Puma::Plugin.new.workers_supported?
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal preload, conf.options.default_options[:preload_app]
|
||||
end
|
||||
|
||||
def test_app_from_rackup
|
||||
conf = Puma::Configuration.new do |c|
|
||||
|
@ -327,6 +283,65 @@ class TestEnvModifificationConfig < TestConfigFileBase
|
|||
end
|
||||
end
|
||||
|
||||
class TestConfigEnvVariables < TestConfigFileBase
|
||||
def test_config_loads_correct_min_threads
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 0, conf.options.default_options[:min_threads]
|
||||
|
||||
with_env("MIN_THREADS" => "7") do
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 7, conf.options.default_options[:min_threads]
|
||||
end
|
||||
|
||||
with_env("PUMA_MIN_THREADS" => "8") do
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 8, conf.options.default_options[:min_threads]
|
||||
end
|
||||
end
|
||||
|
||||
def test_config_loads_correct_max_threads
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal conf.default_max_threads, conf.options.default_options[:max_threads]
|
||||
|
||||
with_env("MAX_THREADS" => "7") do
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 7, conf.options.default_options[:max_threads]
|
||||
end
|
||||
|
||||
with_env("MAX_THREADS" => "8") do
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 8, conf.options.default_options[:max_threads]
|
||||
end
|
||||
end
|
||||
|
||||
def test_config_does_not_load_workers_by_default
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 0, conf.options.default_options[:workers]
|
||||
end
|
||||
|
||||
def test_config_loads_workers_from_env
|
||||
with_env("WEB_CONCURRENCY" => "9") do
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal 9, conf.options.default_options[:workers]
|
||||
end
|
||||
end
|
||||
|
||||
def test_config_does_not_preload_app_if_using_workers
|
||||
with_env("WEB_CONCURRENCY" => "0") do
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal false, conf.options.default_options[:preload_app]
|
||||
end
|
||||
end
|
||||
|
||||
def test_config_preloads_app_if_using_workers
|
||||
with_env("WEB_CONCURRENCY" => "2") do
|
||||
preload = Puma::Plugin.new.workers_supported?
|
||||
conf = Puma::Configuration.new
|
||||
assert_equal preload, conf.options.default_options[:preload_app]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TestConfigFileWithFakeEnv < TestConfigFileBase
|
||||
def setup
|
||||
FileUtils.mkpath("config/puma")
|
||||
|
|
Loading…
Reference in a new issue