class Puma::Server
The HTTP Server
itself. Serves out a single Rack
app.
This class is used by the `Puma::Single` and `Puma::Cluster` classes to generate one or more `Puma::Server` instances capable of handling requests. Each Puma
process will contain one `Puma::Server` instance.
The `Puma::Server` instance pulls requests from the socket, adds them to a `Puma::Reactor` where they get eventually passed to a `Puma::ThreadPool`.
Each `Puma::Server` will have one reactor and one thread pool.
Constants
- ThreadLocalKey
Attributes
@todo the following may be deprecated in the future
@todo the following may be deprecated in the future
@todo the following may be deprecated in the future
@todo the following may be deprecated in the future
@todo the following may be deprecated in the future
@todo the following may be deprecated in the future
Public Class Methods
@!attribute [r] current
# File lib/puma/server.rb, line 116 def current Thread.current[ThreadLocalKey] end
Create a server for the rack app app
.
events
is an object which will be called when certain error events occur to be handled. See Puma::Events
for the list of current methods to implement.
Server#run returns a thread that you can join on to wait for the server to do its work.
@note Several instance variables exist so they are available for testing,
and have default values set via +fetch+. Normally the values are set via `::Puma::Configuration.puma_default_options`.
# File lib/puma/server.rb, line 72 def initialize(app, events=Events.stdio, options={}) @app = app @events = events @check, @notify = nil @status = :stop @auto_trim_time = 30 @reaping_time = 1 @thread = nil @thread_pool = nil @options = options @early_hints = options.fetch :early_hints, nil @first_data_timeout = options.fetch :first_data_timeout, FIRST_DATA_TIMEOUT @min_threads = options.fetch :min_threads, 0 @max_threads = options.fetch :max_threads , (Puma.mri? ? 5 : 16) @persistent_timeout = options.fetch :persistent_timeout, PERSISTENT_TIMEOUT @queue_requests = options.fetch :queue_requests, true @max_fast_inline = options.fetch :max_fast_inline, MAX_FAST_INLINE @io_selector_backend = options.fetch :io_selector_backend, :auto temp = !!(@options[:environment] =~ /\A(development|test)\z/) @leak_stack_on_error = @options[:environment] ? temp : true @binder = Binder.new(events) ENV['RACK_ENV'] ||= "development" @mode = :http @precheck_closing = true @requests_count = 0 end
Public Instance Methods
# File lib/puma/server.rb, line 110 def inherit_binder(bind) @binder = bind end