sign inHome | Recent Changes | All Pages | HelpSearch:

Pound Configuration

Pound a small load balancing proxy server, we’re going to use it to dispatch to multiple mongrel_rails instances (and possibly multiple domain names).

First confirm it’s in your path:



# which pound
/usr/bin/pound

If ‘which’ can’t find pound, then pound is in /usr/local/sbin/. You can add that to your path, or specify the full path whenever you run pound.

Then create an etc directory within your home directory to hold your configuration.



mkdir ~/etc

Then create a pound.conf file that looks like:


        ListenHTTP
            Address 127.0.0.1
            Port    8xxx
                         ## This should be the port    
                         ## assigned to you originally 
                         ## based on your VU number

            Service
                HeadRequire "Host: .*domain.com.*"  
                         ## Matches your domain and all subdomains
                         ## This is a regular expression, so
                         ## the .* means match anything.
                BackEnd
                    Address 127.0.0.1
                    Port    1xxx0 
                         ## Port your mongrel instance is on.
                End

                BackEnd
                    Address 127.0.0.1
                    Port    1xxx1
                         ## Port your second mongrel instance is on (it's 
                         ## recommended you have 2 mongrel instances per app).
                End
            End
        End

Example port numbers (for vu2123): (8xxx, 1xxx0, 1xxx1) => (8123, 11230, 11231)

Please note that for HeadRequire, you should change domain.com to your own website domain. So if your domain is yahoo.com, you should have:

HeadRequire "Host: .*yahoo.com.*"

If you are setting up multiple sites, just add more Service lines to the above configuration with a HeadRequire that matches your other domains and directs them to seperate mongrel ports.

Note for Windows users

If you see an error like ” – abortedective ” ListenHTTP (you have to run pound with the v option to see error messages), it’s probably1 because you edited your pound.conf using Windows. This is probably1 because pound doesn’t like windows-style line breaks. You can use Putty to ssh into your server and create & edit your pound.conf using emacs or vi. This is how we’ve fixed this problem the 2 times it’s appeared so far. There are also scripts available to convert line feed styles, so you can try those, too.

1 This has not been thoroughly tested, so I’m not 100% sure on these yet. More like 90%.

Starting up Pound

$pound -f /path/to/pound.conf

Or, if pound isn’t starting, but not giving you any error messages:

$pound -vf /path/to/pound.conf

Run ps x to see if pound successfully started (there will probably be two pound instances, that’s normal).

Stopping Pound

To stop Pound, first find the pid process. You can do this by typing

$ps x

This will bring up a list of processes. There are usually two pound processes running. An example is shown below:

PID   TTY      STAT   TIME COMMAND 
17514 ?        Ss     0:00 pound -vf pound.conf
17515 ?        Sl     0:00 pound -vf pound.conf
17525 pts/0    R+     0:00 ps x

Just enter

$kill xxx

where xxx is the PID number for the pound process. So in the example above we would type:

$kill 17514

or even

$kill 17515

Killing one pound process kills the other so you won’t have to enter “kill xxx” twice.

You can also try
$ killall pound

which has the property that it kills processes by name. Much easier.

Ensuring your apps start on server reboot

Add the mongrel_rails cluster::start and pound entries to rc.local

Example:


#! /bin/sh

# This script starts programs after a server reboot in a way that
# prevents high server load at server startup.  

# Start Pound on reboot
/usr/local/sbin/pound -f ~/etc/pound.conf

# The next few lines starts my rails application
#( cd ~/rails && ./script/server -d lighttpd )

cd ~/rails
mongrel_rails cluster::configure -e production -p 10720 -N 2

# This generates a mongrel_cluster.yml file in your app's config directory,
# so it only needs to be run once.  This configures mongrel to
# start 2 instances, one at the designated port, the other on the next
# port (port + 1). See below for your available mongrel ports.
mongrel_rails cluster::start

Troubleshooting

If the error message you receive has “Fedora” in it, then this is an apache issue; otherwise it’s with Pound/Mongrel.


Powered by JunebugWiki v0.0.28 Last edited by vu20436 on April 13, 2007 09:04 AM (diff)
Version 5 (current) «olderversions