Apache + Mongrel weirdness

Hi,

I've got Apache modproxing a bunch of mongrels. Everything is peachy. Except...

When I use capistrano to deploy, if someone visits the site in the second or two while the mongrels are being restarted, Apache starts serving 503 errors. I have to restart Apache to get everything to work correctly.

If no one visits the site during the second or two while the mongrels are being restarted, then everything's fine.

Any ideas?

Thanks, Joe

joevandyk@gmail.com wrote:

Hi,

I've got Apache modproxing a bunch of mongrels. Everything is peachy. Except...

When I use capistrano to deploy, if someone visits the site in the second or two while the mongrels are being restarted, Apache starts serving 503 errors. I have to restart Apache to get everything to work correctly.

If no one visits the site during the second or two while the mongrels are being restarted, then everything's fine.

Any ideas?

Thanks, Joe

Hm. Upon investigating it further, it looks like the mongrel_cluster is shutting down and then starting back up. Does it need to do that with capistrano? (I'm using the mongrel_cluster gem).

I'm still confused about why Apache needs to be restarted if it can't communicate properly once with a mongrel process.

Hey Joe-

  Yeah mongrel does need to restart when you push new code. This is why the maintenance.html feature is there. You need a few rewrite rules in your apache vhost like this:

   # If there is a maintenence.html dile in your    # public dir all requests will get rerouted to    # this file.    RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f    RewriteCond %{SCRIPT_FILENAME} !maintenance.html    RewriteRule ^.*$ /maintenance.html [L]

  Then you need to use the capistrano facility for placing a maintenance.html file right in the root of your public dir. With these rewrites and a maintenance.html in public, apache will serve maintenance.html to all requests until the cap task is done updating your code and changin the symlinks.

-Ezra

Ezra Zygmuntowicz wrote:

> >> Hi, >> >> I've got Apache modproxing a bunch of mongrels. Everything is >> peachy. >> Except... >> >> When I use capistrano to deploy, if someone visits the site in the >> second or two while the mongrels are being restarted, Apache starts >> serving 503 errors. I have to restart Apache to get everything to >> work >> correctly. >> >> If no one visits the site during the second or two while the mongrels >> are being restarted, then everything's fine. >> >> Any ideas? >> >> Thanks, >> Joe > > Hm. Upon investigating it further, it looks like the mongrel_cluster > is shutting down and then starting back up. Does it need to do that > with capistrano? (I'm using the mongrel_cluster gem). > > I'm still confused about why Apache needs to be restarted if it can't > communicate properly once with a mongrel process.

Hey Joe-

  Yeah mongrel does need to restart when you push new code. This is why the maintenance.html feature is there. You need a few rewrite rules in your apache vhost like this:

   # If there is a maintenence.html dile in your    # public dir all requests will get rerouted to    # this file.    RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f    RewriteCond %{SCRIPT_FILENAME} !maintenance.html    RewriteRule ^.*$ /maintenance.html [L]

  Then you need to use the capistrano facility for placing a maintenance.html file right in the root of your public dir. With these rewrites and a maintenance.html in public, apache will serve maintenance.html to all requests until the cap task is done updating your code and changin the symlinks.

I had all that set up, but the maintenance.html file was only being created during capistrano's long_deploy. So I'm using that from now on.

Any ideas why Apache would start giving 503 errors forever if it couldn't connect to a Mongrel process once?

Process: start Apache visit site, see 503 errors start mongrel visit site, still see 503 errors restart Apache visit site, don't see 503 errors