Another English post because this might come in handy for some people out there. Some Rails programmers out there may know the problem:
When updating your production server you've just run svn update to update the source of your Rails application. Because of cached code it is also necessary to restart the dispatchers of the Rails application.
Well, I have to admit, until now I simply restarted the Apache2 webserver or killed all dispatcher processes (killall dispatch.fcgi). However since there are quite a few Rails apps running on my server this always killed the other dispatchers, too. This isn't really a problem but more of "unnecessary brute force". The perfect solution would be to find the exact dispatcher of the Rails application I want to update and just kill this one.
But how? ps -A | grep dispatch.fcgi only prints out the PIDs of the dispatchers but not the paths. To work around this and I created a little script: find_dispatcher.rb.
It analyses the Apache log file and shows the data of every log entry where an FCGID dispatcher was started.
ruby find_dispatcher.rb 1722 Fri Jul 06 18:59:01 2007 /path/to/project/a/public/dispatch.fcgi 1755 Fri Jul 06 19:11:52 2007 /path/to/project/b/public/dispatch.fcgi 4615 Sat Jul 07 14:49:14 2007 /path/to/project/c/public/dispatch.fcgi 4931 Sat Jul 07 16:20:30 2007 /path/to/project/d/public/dispatch.fcgi
It's possible to specify a filter to just see the dispatchers created for a single project:
ruby find_dispatcher.rb -f project/b 1755 Fri Jul 06 19:11:52 2007 /path/to/project/b/public/dispatch.fcgi
To combine this script with others the --only-last-pid (or -p) option just prints out the last PID:>
ruby find_dispatcher.rb -f project/b -p 1755
By default the script searches the /var/log/apache2/error.log file for matching entries. You can specify your own log file with the --log (-l for short) option.
ruby find_dispatcher.rb --log /my/own/log/file.log
This is it. --help will show an overview of all options. You can get the script directly out of my SubVersion repository: find_dispatcher.rb. Much fun with it.