Jul 14

Configure Mongrel cluster for Rails

wzuup mongrel

Go to the rails app directory.

$ cd /var/rails/wzuup

Configure the mongrel cluster for this rails app.

$ mongrel_rails cluster::configure -a -p 8000 -N 1 -e production -c /var/rails/wzuup 
Writing configuration file to config/mongrel_cluster.yml.

If server should run under www.example.com/wzuup. The new --prefix $APP_ROOT command allows Mongrel Applications to properly ignore the prefix. Prior to this enhancement, the web server (not mongrel) needed to be configured to strip out the prefix.

$ mongrel_rails cluster::configure -e production -p 8000 -N 2 -c /var/rails/wzuup -a --prefix /wzuup

The syntax is very easy to understand. * listen to localhost only -a * use port 8000 -p 8000 * start only one mongrel server Important: for N=3 three servers with ports 8000, 8001 and 8002 will be used -N 1 * run the rails app in the production environment -e production * the root of the rails app -c /var/rails/wzuup

Start the mongrel cluster

$ mongrel_rails cluster::start
starting port 8000

Check if mongrel servers are running

$ ps ax | grep mongrel
 6836 ?        Sl     0:01 /usr/bin/ruby1.8 /usr/bin/mongrel_rails start -d -e production -a -c /var/rails/wzuup -p 8000 -P tmp/pids/mongrel.8000.pid -l log/mongrel.8000.log
 6844 pts/0    R+     0:00 grep mongrel

Stop the mongrel cluster

$ mongrel_rails cluster::stop
stopping port 8000
✱ ✱ ✱