lib/raindrops/middleware.rb in raindrops-0.1.0 vs lib/raindrops/middleware.rb in raindrops-0.2.0

- old
+ new

@@ -11,19 +11,24 @@ PATH_INFO = "PATH_INFO" # :startdoc: def initialize(app, opts = {}) super(app, opts[:stats] || Stats.new, opts[:path] || "/_raindrops") - if tmp = opts[:listeners] + tmp = opts[:listeners] + if tmp.nil? && defined?(Unicorn) && Unicorn.respond_to?(:listener_names) + tmp = Unicorn.listener_names + end + + if tmp self.tcp = tmp.grep(/\A[^:]+:\d+\z/) self.unix = tmp.grep(%r{\A/}) self.tcp = nil if tcp.empty? self.unix = nil if unix.empty? end end - # standard Rack endpoing + # standard Rack endpoint def call(env) env[PATH_INFO] == path ? stats_response : dup._call(env) end def _call(env) @@ -43,11 +48,10 @@ end # the Rack server should call this after #each (usually ensure-d) def close stats.decr_writing - ensure - app.close if app.respond_to?(:close) + app.close if app.respond_to?(:close) end def stats_response body = "calling: #{stats.calling}\n" \ "writing: #{stats.writing}\n"