lib/rack/handler/mongrel2.rb in m2r-2.0.2 vs lib/rack/handler/mongrel2.rb in m2r-2.1.0.pre
- old
+ new
@@ -11,13 +11,17 @@
'send_addr' => 'tcp://127.0.0.1:9996',
'sender_id' => SecureRandom.uuid
}
def self.run(app, options = {})
- options = OpenStruct.new( DEFAULT_OPTIONS.merge(options) )
- parser = M2R::Request
- adapter = M2R::RackHandler.new(app, connection_factory(options), parser)
+ options = OpenStruct.new( DEFAULT_OPTIONS.merge(options) )
+ threadsafe_parser = M2R::Parser.new
+ adapter = M2R::RackHandler.new(app, connection_factory(options), threadsafe_parser)
+ graceful = Proc.new { adapter.stop }
+ trap("INT", &graceful)
+ trap("TERM", &graceful)
adapter.listen
+ M2R.zmq_context.terminate
end
def self.valid_options
{
'recv_addr=RECV_ADDR' => 'Receive address',