Reaper spawner

Hi,

Anyone know where i can find out more info on Reaper/Spawner.

Currently, every time i add a new account on my production machine, i
have to restart the whole server. After about 150 accounts, this puts a
real strain on the server (it takes 3 full minutes before i can access
any site on the server).

I think reaper/spawner is my answer, but i am havving trouble figuring
out how to use it.

Any help would be appreciated.

thanks
jake

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…

On 12/14/06, Jake V. [email protected] wrote:


Posted via http://www.ruby-forum.com/.


seth at subimage interactive
http://www.subimage.com/sublog/

what if you have multiple apps?

Will have you have to keep track of ports?

Here is a snippet from my lightty config:

$HTTP[“host”] == “demo3023.djdossiers.com” {
server.document-root = “/sites/djd_sites/demo/demo_3023/public/”
server.error-handler-404 = “/dispatch.fcgi”
server.indexfiles = ( “dispatch.fcgi”, “index.html”)
accesslog.format = “%h %l %u %t "%r" %>s %b "%{Referer}i"
"%{User-agent}i"”

  server.errorlog = 

“/sites/djd_sites/demo/demo_3023/log/lighttpd.error.log”
accesslog.filename =
“/sites/djd_sites/demo/demo_3023/log/lighttpd.access.log”
fastcgi.server = ( “.fcgi” =>
( “demo_3023_djdossiers.com” =>
( “socket” => “/tmp/demo_3023_djdossiers.socket”,
“min-procs” => 1,
“max-procs” => 1,
“bin-path” =>
“/sites/djd_sites/demo/demo_3023/public/dispatch.fcgi”,
“bin-environment” => ( “RAILS_ENV” => “production” ))
))
}

how would i use the spawner script in that instance? Also, When I add a
new demo or account, will i have to restart light because of the
additional http snippet that will need to be added?

thanks
jake

Subimage Interactive wrote:

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…

On 12/14/06, Jake V. [email protected] wrote:


Posted via http://www.ruby-forum.com/.


seth at subimage interactive
http://www.subimage.com/sublog/

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.

On 12/14/06, Jake V. [email protected] wrote:

  server.error-handler-404   = "/dispatch.fcgi"
    ( "demo_3023_djdossiers.com" =>

how would i use the spawner script in that instance? Also, When I add a

Jake, you want to use Lighttpd/FCGI to get this done…Apache/FCGI will

it is included:
want


seth at subimage interactive
http://www.subimage.com/sublog/