class Rack::Handler::Trinidad
Public Class Methods
create_servlet(app)
click to toggle source
# File lib/rack/handler/trinidad.rb, line 47 def self.create_servlet(app) context = org.jruby.rack.embed.Context.new('Trinidad') dispatcher = org.jruby.rack.embed.Dispatcher.new(context, self.new(app)) org.jruby.rack.embed.Servlet.new(dispatcher, context) end
parse_options(options = {})
click to toggle source
# File lib/rack/handler/trinidad.rb, line 30 def self.parse_options(options = {}) # some libs use :Port, :port and :Host, :host, unify this opts = {} options.each { |k, v| opts[k.to_s.downcase.to_sym] = v } # this is rack's configuration file but also the trinidad's configuration. # Removing it we allow to load trinidad's default configuration. opts.delete(:config) threads = (opts[:threads] || '1:1').split(':') opts[:port] ||= 3000 opts[:address] ||= opts[:host] || 'localhost' # NOTE: this is currently not supported by embedded Dispatcher and has no effect : opts[:jruby_min_runtimes], opts[:jruby_max_runtimes] = threads[0].to_i, threads[1].to_i opts end
run(app, options={}) { |server| ... }
click to toggle source
# File lib/rack/handler/trinidad.rb, line 12 def self.run(app, options={}) opts = parse_options(options) opts[:rack_servlet] = create_servlet(app) ::Trinidad::CommandLineParser.load(opts) server = ::Trinidad::Server.new yield server if block_given? server.start end
valid_options()
click to toggle source
# File lib/rack/handler/trinidad.rb, line 22 def self.valid_options { "Host=HOST" => "Hostname to listen on (default: localhost)", "Port=PORT" => "Port to listen on (default: 8080)", #"Threads=MIN:MAX" => "min:max runtimes to use (default 1:1, threadsafe)", } end