4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/cypress-rails/server/puma.rb', line 4
def self.create(app, port, host)
require "rack/handler/puma"
default_options = {Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false}
options = default_options
puma_rack_handler = defined?(Rackup::Handler::Puma) ? Rackup::Handler::Puma : Rack::Handler::Puma
conf = puma_rack_handler.config(app, options)
conf.clamp
logger = (defined?(::Puma::LogWriter) ? ::Puma::LogWriter : ::Puma::Events).stdio
puma_ver = Gem::Version.new(::Puma::Const::PUMA_VERSION)
require_relative "patches/puma_ssl" if (Gem::Version.new("4.0.0")...Gem::Version.new("4.1.0")).cover? puma_ver
logger.log "Starting Puma..."
logger.log "* Version #{::Puma::Const::PUMA_VERSION} , codename: #{::Puma::Const::CODE_NAME}"
logger.log "* Min threads: #{conf.options[:min_threads]}, max threads: #{conf.options[:max_threads]}"
::Puma::Server.new(conf.app, defined?(::Puma::LogWriter) ? nil : logger, conf.options).tap do |s|
s.binder.parse conf.options[:binds], s.respond_to?(:log_writer) ? s.log_writer : s.events
s.min_threads, s.max_threads = conf.options[:min_threads], conf.options[:max_threads] if s.respond_to?(:min_threads=)
end.run.join
end
|