Class: Rack::Handler::Mongrel2
- Inherits:
-
Object
- Object
- Rack::Handler::Mongrel2
- Defined in:
- lib/rack/handler/mongrel2.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ 'recv_addr' => 'tcp://127.0.0.1:9997', 'send_addr' => 'tcp://127.0.0.1:9996', 'sender_id' => SecureRandom.uuid }
Class Method Summary collapse
Class Method Details
.connection_factory(options) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rack/handler/mongrel2.rb', line 34 def self.connection_factory() klass = if custom = .connection_factory begin M2R::ConnectionFactory.const_get(custom.classify) rescue NameError require "m2r/connection_factory/#{custom.underscore}" M2R::ConnectionFactory.const_get(custom.classify) end else M2R::ConnectionFactory end klass.new() end |
.run(app, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rack/handler/mongrel2.rb', line 15 def self.run(app, = {}) = OpenStruct.new( DEFAULT_OPTIONS.merge() ) threadsafe_parser = M2R::Parser.new adapter = M2R::RackHandler.new(app, connection_factory(), threadsafe_parser) graceful = Proc.new { adapter.stop } trap("INT", &graceful) trap("TERM", &graceful) adapter.listen M2R.zmq_context.terminate end |
.valid_options ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/rack/handler/mongrel2.rb', line 26 def self. { 'recv_addr=RECV_ADDR' => 'Receive address', 'send_addr=SEND_ADDR' => 'Send address', 'sender_id=UUID' => 'Sender UUID' } end |