class Rack::ProcTitle

Middleware to update the process title ($0) with information about the current request. Based loosely on:

NOTE: This will not work properly in a multi-threaded environment.

Constants

F
PROGNAME

Public Class Methods

new(app) click to toggle source
   # File lib/rack/contrib/proctitle.rb
14 def initialize(app)
15   @app = app
16   @appname = Dir.pwd.split('/').reverse.
17     find { |name| name !~ /^(\d+|current|releases)$/ } || PROGNAME
18   @requests = 0
19   $0 = "#{PROGNAME} [#{@appname}] init ..."
20 end

Public Instance Methods

call(env) click to toggle source
   # File lib/rack/contrib/proctitle.rb
22 def call(env)
23   host, port = env['SERVER_NAME'], env['SERVER_PORT']
24   meth, path = env['REQUEST_METHOD'], env['PATH_INFO']
25   @requests += 1
26   $0 = "#{PROGNAME} [#{@appname}/#{port}] (#{@requests}) " \
27        "#{meth} #{path}"
28 
29   @app.call(env)
30 end