class Puma::Server
def initialize(app, events = nil, options = {})
- Note: - The `events` parameter is set to nil, and set to `Events.new` in code.
Note: - Several instance variables exist so they are available for testing,
def initialize(app, events = nil, options = {}) @app = app @events = events || Events.new @check, @notify = nil @status = :stop @thread = nil @thread_pool = nil @options = if options.is_a?(UserFileDefaultOptions) options else UserFileDefaultOptions.new(options, Configuration::DEFAULTS) end @clustered = (@options.fetch :workers, 0) > 0 @worker_write = @options[:worker_write] @log_writer = @options.fetch :log_writer, LogWriter.stdio @early_hints = @options[:early_hints] @first_data_timeout = @options[:first_data_timeout] @persistent_timeout = @options[:persistent_timeout] @idle_timeout = @options[:idle_timeout] @min_threads = @options[:min_threads] @max_threads = @options[:max_threads] @queue_requests = @options[:queue_requests] @max_fast_inline = @options[:max_fast_inline] @enable_keep_alives = @options[:enable_keep_alives] @io_selector_backend = @options[:io_selector_backend] @http_content_length_limit = @options[:http_content_length_limit] # make this a hash, since we prefer `key?` over `include?` @supported_http_methods = if @options[:supported_http_methods] == :any :any else if (ary = @options[:supported_http_methods]) ary else SUPPORTED_HTTP_METHODS end.sort.product([nil]).to_h.freeze end temp = !!(@options[:environment] =~ /\A(development|test)\z/) @leak_stack_on_error = @options[:environment] ? temp : true @binder = Binder.new(log_writer) ENV['RACK_ENV'] ||= "development" @mode = :http @precheck_closing = true @requests_count = 0 @idle_timeout_reached = false end