1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00
puma--puma/lib/puma.rb
MSP-Greg 37f47cad94
Move ssl detection to puma.rb (#2541)
puma.rb loads puma/puma_http11, which contains the compiled c code for ssl.  Move ssl detection from puma/detect.rb to puma.rb
2021-02-01 14:10:28 -07:00

61 lines
1.3 KiB
Ruby

# frozen_string_literal: true
# Standard libraries
require 'socket'
require 'tempfile'
require 'time'
require 'etc'
require 'uri'
require 'stringio'
require 'thread'
require 'puma/puma_http11'
require 'puma/detect'
require 'puma/json'
module Puma
autoload :Const, 'puma/const'
autoload :Server, 'puma/server'
autoload :Launcher, 'puma/launcher'
# at present, MiniSSL::Engine is only defined in extension code (puma_http11),
# not in minissl.rb
HAS_SSL = const_defined?(:MiniSSL, false) && MiniSSL.const_defined?(:Engine, false)
if HAS_SSL
require 'puma/minissl'
else
module MiniSSL
# this class is defined so that it exists when Puma is compiled
# without ssl support, as Server and Reactor use it in rescue statements.
class SSLError < StandardError ; end
end
end
def self.ssl?
HAS_SSL
end
# @!attribute [rw] stats_object=
def self.stats_object=(val)
@get_stats = val
end
# @!attribute [rw] stats_object
def self.stats
Puma::JSON.generate @get_stats.stats
end
# @!attribute [r] stats_hash
# @version 5.0.0
def self.stats_hash
@get_stats.stats
end
# Thread name is new in Ruby 2.3
def self.set_thread_name(name)
return unless Thread.current.respond_to?(:name=)
Thread.current.name = "puma #{name}"
end
end