Skip to content
Browse files

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.
  • Loading branch information...
1 parent 9114e3c commit 963cbfc8138d9980a2a3449ee60be948baad6182 @evanphx evanphx committed Sep 10, 2012
Showing with 46 additions and 6 deletions.
  1. +18 −2 lib/puma/binder.rb
  2. +25 −4 lib/puma/cli.rb
  3. +3 −0 lib/puma/const.rb
View
20 lib/puma/binder.rb
@@ -98,18 +98,23 @@ def parse(binds, logger)
@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 @@ def inherit_tcp_listener(host, port, fd)
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 @@ def add_ssl_listener(host, port, ctx,
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
View
29 lib/puma/cli.rb
@@ -88,7 +88,7 @@ def restart!
blk.call self
end
- if IS_JRUBY
+ if jruby?
@binder.listeners.each_with_index do |(str,io),i|
io.close
@@ -136,6 +136,20 @@ def debug(str)
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 @@ def setup_options
"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 @@ def setup_options
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 @@ def graceful_stop(server)
# for it to finish.
#
def run
- parse_options
+ begin
+ parse_options
+ rescue UnsupportedOption
+ exit 1
+ end
clustered = @options[:workers] > 0
View
3 lib/puma/const.rb
@@ -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

0 comments on commit 963cbfc

Please sign in to comment.
Something went wrong with that request. Please try again.