Jake, you want to use Lighttpd/FCGI to get this done…Apache/FCGI will not work for this kind of a setup. I hear mongrel works well also, but I haven’t done a deployment using mongrel just yet. I just went through such a thing so hopefully this helps you out a little.
The magic is in Lighty’s fastcgi.server setup…here’s a copy of mine from a deployment I’ve done…
fastcgi.server = ( “.fcgi” => (“edeals-7000” => ( “host” => " 127.0.0.1", “port” => 7000 ) ), (“edeals-7001” => ( “host” => “127.0.0.1”, “port” => 7001 ) ),
(“edeals-7002” => ( “host” => “127.0.0.1”, “port” => 7002 ) ), (“edeals-7003” => ( “host” => " 127.0.0.1", “port” => 7003 ) ) )
It proxies requests to the selected ports set up here. This way you can restart your fcgi servers by doing the following from your capistrano restart task.
run “#{release_path}/script/process/killer” run “#{release_path}/script/process/spawner -p 7000 -i 4 -r 60 -d #{release_path}/public/dispatch.fcgi”
I have spawner set up to restart fallen down processes every 60 seconds, so the built in reaper script doesn’t do me much good. I’ve written a ‘killer’ script that stops the daemon as well as the fcgis before I re-spawn…here it is included:
#!/bin/sh
Kill all spawner processes
ps auxw | grep spawner | grep deploy | awk ‘{print $2}’ | xargs kill -9;
Kill all dispatch processes
ps auxw | grep dispatch | grep deploy | awk ‘{print $2}’ | xargs kill -9;
exit 0;
‘deploy’ is my username that the application is running under. You will want to change this depending on your setup / users.
Hope that helped a little…