Al Evans
2006-Jun-21 15:16 UTC
[Rails] [ANN] fcgi_watch (reaper replacement for shared servers)
fcgi_watch is a supplement to (or replacement for) <rails_app>/script/process/reaper. The standard reaper script searches for all processes started with a given pathname using the output from a ps command, and performs an action on them. There are problems with this approach, at least on some shared servers: - The pathname seen from a script is not necessarily the same as the pathname seen from a shell command. You can determine whether you have this problem by typing a pwd command, then ruby -e ''puts `pwd`''. If the results are different, the problem exists. - At least on some servers, if you have two or more Rails applications running, all of the FCGI dispatchers will look the same to the ps command. This means that any action performed by reaper will affect all your Rails applications. HOW DOES fcgi_watch SOLVE THESE PROBLEMS? fcgi_watch finds and parses the fastcgi.crash.log in the <rails_app>/log directory. It makes a list of processes that should be running, then cross-checks it against the output of ps to find all the FCGI processes that are actually running for a specified application. Only then does it perform the specified action. BUT THAT''S NOT ALL! Managing FastCGI processes on a shared server is sometimes problematical. You have little control over the web server used, over its configuration, or over the activities of other users. Your dispatchers might get swapped out and become "unresponsive", causing the server to start new ones. After a day or so, "ps aux" might show eight or ten copies of dispatch.fcgi -- more, if you have multiple applications -- and you have no way of knowing which ones of them can be safely killed. fcgi_watch provides an "expire" action, in addition to the actions provided by reaper. fcgi_watch keeps track of the ages of instances of dispatch.fcgi, and can "expire" processes older than a given number of hours. You can also set a maximum number of FCGI dispatchers that you want to allow for a given application. "fcgi_watch expire" will terminate the extras -- gracefully, if possible. You can get fcgi_watch here: http://www.alevans.com/dl/fcgi_watch-0.3.0.tgz I wrote fcgi_watch to solve my FCGI management problems, and it''s made my life easier. Hope it helps someone else out!:-) Please email me with any problems, suggestions, improvements, etc. --Al Evans -- Posted via http://www.ruby-forum.com/.