mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Log puma config if the env variable LOG_CONFIG exists (#2472)
This commit is contained in:
parent
5f8b5fc407
commit
c1b6071ae3
6 changed files with 48 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
* Features
|
* Features
|
||||||
* Your feature goes here <Most recent on the top, like GitHub> (#Github Number)
|
* Your feature goes here <Most recent on the top, like GitHub> (#Github Number)
|
||||||
|
* Prints the loaded configuration if the environment variable `PUMA_LOG_CONFIG` is present ([#2472])
|
||||||
* Integrate with systemd's watchdog and notification features ([#2438])
|
* Integrate with systemd's watchdog and notification features ([#2438])
|
||||||
* Adds max_fast_inline as a configuration option for the Server object ([#2406])
|
* Adds max_fast_inline as a configuration option for the Server object ([#2406])
|
||||||
* You can now fork workers from worker 0 using SIGURG w/o fork_worker enabled [#2449]
|
* You can now fork workers from worker 0 using SIGURG w/o fork_worker enabled [#2449]
|
||||||
|
|
|
@ -85,6 +85,9 @@ Puma provides numerous options. Consult `puma -h` (or `puma --help`) for a full
|
||||||
You can also find several configuration examples as part of the
|
You can also find several configuration examples as part of the
|
||||||
[test](https://github.com/puma/puma/tree/master/test/config) suite.
|
[test](https://github.com/puma/puma/tree/master/test/config) suite.
|
||||||
|
|
||||||
|
For debugging purposes, you can set the environment variable `PUMA_LOG_CONFIG` with a value
|
||||||
|
and the loaded configuration will be printed as part of the boot process.
|
||||||
|
|
||||||
### Thread Pool
|
### Thread Pool
|
||||||
|
|
||||||
Puma uses a thread pool. You can set the minimum and maximum number of threads that are available in the pool with the `-t` (or `--threads`) flag:
|
Puma uses a thread pool. You can set the minimum and maximum number of threads that are available in the pool with the `-t` (or `--threads`) flag:
|
||||||
|
|
|
@ -92,6 +92,12 @@ module Puma
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def final_options
|
||||||
|
default_options
|
||||||
|
.merge(file_options)
|
||||||
|
.merge(user_options)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# The main configuration class of Puma.
|
# The main configuration class of Puma.
|
||||||
|
@ -290,6 +296,10 @@ module Puma
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def final_options
|
||||||
|
@options.final_options
|
||||||
|
end
|
||||||
|
|
||||||
def self.temp_path
|
def self.temp_path
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,8 @@ module Puma
|
||||||
Puma.stats_object = @runner
|
Puma.stats_object = @runner
|
||||||
|
|
||||||
@status = :run
|
@status = :run
|
||||||
|
|
||||||
|
log_config if ENV['PUMA_LOG_CONFIG']
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :binder, :events, :config, :options, :restart_dir
|
attr_reader :binder, :events, :config, :options, :restart_dir
|
||||||
|
@ -521,5 +523,14 @@ module Puma
|
||||||
Bundler.with_unbundled_env { yield }
|
Bundler.with_unbundled_env { yield }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def log_config
|
||||||
|
log "Configuration:"
|
||||||
|
|
||||||
|
@config.final_options
|
||||||
|
.each { |config_key, value| log "- #{config_key}: #{value}" }
|
||||||
|
|
||||||
|
log "\n"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -265,6 +265,13 @@ class TestConfigFile < TestConfigFileBase
|
||||||
assert_equal 0, Puma::Configuration.new.options.default_options[:workers]
|
assert_equal 0, Puma::Configuration.new.options.default_options[:workers]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_final_options_returns_merged_options
|
||||||
|
conf = Puma::Configuration.new({ min_threads: 1, max_threads: 2 }, { min_threads: 2 })
|
||||||
|
|
||||||
|
assert_equal 1, conf.final_options[:min_threads]
|
||||||
|
assert_equal 2, conf.final_options[:max_threads]
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def assert_run_hooks(hook_name, options = {})
|
def assert_run_hooks(hook_name, options = {})
|
||||||
|
|
|
@ -158,6 +158,22 @@ class TestLauncher < Minitest::Test
|
||||||
launcher.run
|
launcher.run
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_log_config_enabled
|
||||||
|
ENV['PUMA_LOG_CONFIG'] = "1"
|
||||||
|
|
||||||
|
assert_match(/Configuration:/, launcher.events.stdout.string)
|
||||||
|
|
||||||
|
launcher.config.final_options.each do |config_key, _value|
|
||||||
|
assert_match(/#{config_key}/, launcher.events.stdout.string)
|
||||||
|
end
|
||||||
|
|
||||||
|
ENV.delete('PUMA_LOG_CONFIG')
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_log_config_disabled
|
||||||
|
refute_match /Configuration:/, launcher.events.stdout.string
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def events
|
def events
|
||||||
|
|
Loading…
Add table
Reference in a new issue