Rack Proctitle Contest winner

Added by arya at October 09, 2009 16:51 Star_small_grayStar_small_grayStar_small_grayStar_small_grayStar_small_gray
GitHub stats:
Magnifier watcher(s)
Arrow_branch fork(s)
Wrench

About

Allows you to see what request a given server process is handling.

Details

By running "watch -n 0.1 ‘ps aux | grep “USER\|rack” ’ you can see all your rack processes, what request they’re currently handling and for how long (or if they’re idle), what their last request was and how long it took, how many requests have been handled in the life of this process, and the requests in queue.

It ends up being really useful to diagnose problems.

Example output:
rack/14a0b0 [1/682]: handling 0.0s /users/6014086

You can set a prefix, which will replace “rack” in the line above, and you can set an APPLICATION_VERSION constant which will be after the prefix. You can use this to distinguish between different rack processes if you run multiple applications on the same machine.

It’s based off Ryan Tomayko’s Mongrel Proctitle but has more features and is Rack compatible.

Usage

In some file somewhere (optional):
APPLICATION_VERSION = File.read(File.join(RAILS_ROOT, “REVISION”))[0,6] # if you use capistrano which creates the REVISION file

In your rackup file (prefix is optional):
use RackProctitle, :prefix => “application_name”

We use watch to get a continuously updating status of our rack processes:
watch -n 0.1 ‘ps aux | grep “USER\|application_name” | grep -v grep ; uptime; hostname’

blog comments powered by Disqus