taken from http://rubyists.com/articles/2005/05/03/spawn-fcgi-in-the-foreground: spawn-fcgi in the foreground! by Bougyman Tue, 03 May 2005 11:00:00 GMT Been looking for a clean way to spawn fastcgi listeners in the foreground and I believe Trey has figured it out. This patch should take care of it by keeping spawn-fcgi from losing track of the copied listening processes and allow full supervison. To use, call your cgi-fcgi -start -connect $host:$port script with the -supervise option, like: cgi-fcgi -start -supervise -connect 127.0.0.1:1791 /path/to/dispatch.fcgi Full Supervise run script becomes #!/bin/sh RAIL_NUMBER=$(basename $PWD|awk -F'-' '{print $2}') RAILS_HOST=$( contains one line that is the full path to your rails root directory. RAILS_ENV => contains one word, either ‘production’ or ‘development’ RAILS_HOST => contains one IP address or FQDN You can set any other environment variables in this way by simply creating a file with the variable name and its contents will become the value of that environment variable. Because of the envdir ./env call before the cgi-fcgi call, your rails application has access to any variables set in this way.