reaper spawner

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…

I believe so yes, you will have to restart lighty when you add an account - but you won’t have to restart it any time you update your rails apps.

You will have to keep track of your ports. Spawner uses the -p and -i flags to determine what port the processes start at, and how many to start.

run "#{release_path}/script

/process/spawner -p 7000 -i 4 -r 60 -d #{release_path}/public/dispatch.fcgi"

In that instance, -p is telling spawner to start at port 7000, and the -i flag is telling it how many fcgi instances to start (4)

In your config you have lighty spawning the FCGI scripts, which won’t work well for a multiple-user scenario, as you’ll have to restart lighty any time someone makes a change to their app.

The way I have my fcgi config setup is that it proxies the requests to the ports setup.

This is the best way I’ve found to do such a thing currently…but I’m definitely no rails deployment wizard. I’d be really interested to hear someone else chime in on the subject. I’ve actually been looking for someone to subcontract out some work to with that type of skill set from time to time.