mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Disable worker processes (jruby, win32) and SSL (jruby)
JRuby has at present too many bugs to do nonblocking SSL properly. Until MiniSSL has JRuby support, SSL support has to be disabled.
This commit is contained in:
parent
9114e3c9d2
commit
963cbfc813
3 changed files with 46 additions and 6 deletions
|
@ -98,18 +98,23 @@ module Puma
|
|||
|
||||
@listeners << [str, io]
|
||||
when "ssl"
|
||||
if IS_JRUBY
|
||||
@events.error "SSL not supported on JRuby"
|
||||
raise UnsupportedOption
|
||||
end
|
||||
|
||||
params = Rack::Utils.parse_query uri.query
|
||||
require 'puma/minissl'
|
||||
|
||||
ctx = MiniSSL::Context.new
|
||||
unless params['key']
|
||||
error "Please specify the SSL key via 'key='"
|
||||
@events.error "Please specify the SSL key via 'key='"
|
||||
end
|
||||
|
||||
ctx.key = params['key']
|
||||
|
||||
unless params['cert']
|
||||
error "Please specify the SSL cert via 'cert='"
|
||||
@events.error "Please specify the SSL cert via 'cert='"
|
||||
end
|
||||
|
||||
ctx.cert = params['cert']
|
||||
|
@ -181,6 +186,11 @@ module Puma
|
|||
|
||||
def add_ssl_listener(host, port, ctx,
|
||||
optimize_for_latency=true, backlog=1024)
|
||||
if IS_JRUBY
|
||||
@events.error "SSL not supported on JRuby"
|
||||
raise UnsupportedOption
|
||||
end
|
||||
|
||||
require 'puma/minissl'
|
||||
|
||||
s = TCPServer.new(host, port)
|
||||
|
@ -200,6 +210,12 @@ module Puma
|
|||
end
|
||||
|
||||
def inherited_ssl_listener(fd, ctx)
|
||||
if IS_JRUBY
|
||||
@events.error "SSL not supported on JRuby"
|
||||
raise UnsupportedOption
|
||||
end
|
||||
|
||||
require 'puma/minissl'
|
||||
s = TCPServer.for_fd(fd)
|
||||
@ios << MiniSSL::Server.new(s, ctx)
|
||||
s
|
||||
|
|
|
@ -88,7 +88,7 @@ module Puma
|
|||
blk.call self
|
||||
end
|
||||
|
||||
if IS_JRUBY
|
||||
if jruby?
|
||||
@binder.listeners.each_with_index do |(str,io),i|
|
||||
io.close
|
||||
|
||||
|
@ -136,6 +136,20 @@ module Puma
|
|||
end
|
||||
end
|
||||
|
||||
def jruby?
|
||||
IS_JRUBY
|
||||
end
|
||||
|
||||
def windows?
|
||||
RUBY_PLATFORM =~ /mswin32|ming32/
|
||||
end
|
||||
|
||||
def unsupported(str, cond=true)
|
||||
return unless cond
|
||||
@events.error str
|
||||
raise UnsupportedOption
|
||||
end
|
||||
|
||||
# Build the OptionParser object to handle the available options.
|
||||
#
|
||||
def setup_options
|
||||
|
@ -186,8 +200,8 @@ module Puma
|
|||
"Use 'auto' to use temp unix server" do |arg|
|
||||
if arg
|
||||
@options[:control_url] = arg
|
||||
elsif IS_JRUBY
|
||||
raise NotImplementedError, "No default url available on JRuby"
|
||||
elsif jruby?
|
||||
unsupported "No default url available on JRuby"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -209,6 +223,9 @@ module Puma
|
|||
|
||||
o.on "-w", "--workers COUNT",
|
||||
"Activate cluster mode: How many worker processes to create" do |arg|
|
||||
unsupported "-w not supported on JRuby and Windows",
|
||||
jruby? || windows?
|
||||
|
||||
@options[:workers] = arg.to_i
|
||||
end
|
||||
|
||||
|
@ -298,7 +315,11 @@ module Puma
|
|||
# for it to finish.
|
||||
#
|
||||
def run
|
||||
parse_options
|
||||
begin
|
||||
parse_options
|
||||
rescue UnsupportedOption
|
||||
exit 1
|
||||
end
|
||||
|
||||
clustered = @options[:workers] > 0
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require 'rack'
|
||||
|
||||
module Puma
|
||||
class UnsupportedOption < RuntimeError
|
||||
end
|
||||
|
||||
|
||||
# Every standard HTTP code mapped to the appropriate message. These are
|
||||
# used so frequently that they are placed directly in Puma for easy
|
||||
|
|
Loading…
Add table
Reference in a new issue