# \[ANN\] fcgi\_watch (reaper replacement for shared servers)

**URL:** <https://www.ruby-forum.com/t/ann-fcgi-watch-reaper-replacement-for-shared-servers/64052>\
**Category:** Rails\
**Created:** [June 21, 2006, 5:16pm UTC](https://www.ruby-forum.com/t/ann-fcgi-watch-reaper-replacement-for-shared-servers/64052 "2006-06-21T17:16:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [June 21, 2006, 5:16pm UTC](https://www.ruby-forum.com/t/ann-fcgi-watch-reaper-replacement-for-shared-servers/64052/1 "2006-06-21T17:16:01Z")

</div>

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](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
