Sha256: d425bb78628cfb20482b0f27f8e44065599ab56fe215a17d14f180609805efa5
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'mongrel2/connection' require 'stringio' require 'eventmachine' module Rack module Handler class Mongrel2 class << self def run(app, options = {}) options = { :recv => ENV['RACK_MONGREL2_RECV'] || 'tcp://127.0.0.1:9997', :send => ENV['RACK_MONGREL2_SEND'] || 'tcp://127.0.0.1:9996', :uuid => ENV['RACK_MONGREL2_UUID'] }.merge(options) raise ArgumentError.new('Must specify an :uuid or set RACK_MONGREL2_UUID') if options[:uuid].nil? conn = nil EM.run do conn = ::Mongrel2::Connection.new(options[:uuid], options[:recv], options[:send], app) # This doesn't work at all until zmq fixes their shit (in 2.1.x I think), but trap it now anyway. %w(INT TERM KILL).each do |sig| trap(sig) do conn.close EM.stop end end end ensure conn.close if conn.respond_to?(:close) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
em-rack-mongrel2-0.1.0 | lib/rack/handler/mongrel2.rb |