Created
October 6, 2009 18:13
-
-
Save tomlea/203262 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rack::ProcTitle | |
F = ::File | |
PROGNAME = F.basename($0) | |
def initialize(app) | |
@app = app | |
@appname = Dir.pwd.split('/').reverse. | |
find { |name| name !~ /^(\d+|current|releases)$/ } || PROGNAME | |
@requests = 0 | |
$0 = "#{PROGNAME} [#{@appname}] init ..." | |
end | |
def call(env) | |
host, port = env['SERVER_NAME'], env['SERVER_PORT'] | |
meth, path = env['REQUEST_METHOD'], env['PATH_INFO'] | |
@requests += 1 | |
$0 = "#{PROGNAME} [#{@appname}/#{port}] (#{@requests}) " \ | |
"#{meth} #{path}" | |
@app.call(env) | |
ensure | |
$0 = "#{PROGNAME} [#{@appname}/#{port}] (#{@requests}) idle..." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exactly right.