Skip to content

Instantly share code, notes, and snippets.

@tomlea
Created October 6, 2009 18:13
Show Gist options
  • Save tomlea/203262 to your computer and use it in GitHub Desktop.
Save tomlea/203262 to your computer and use it in GitHub Desktop.
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
@deepak
Copy link

deepak commented Jun 22, 2011

the "@request+=1" seems redundant

@deepak
Copy link

deepak commented Jun 22, 2011

oh ok..makes sense now, It shows the total number of requests served by the app
eg. if apache/passenger respawns the process, it again start incrementing from zero

@tomlea
Copy link
Author

tomlea commented Jun 22, 2011

Exactly right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment