Rails

Remember to logout often when testing cached user objects…

I’m sure I’m not the first to do this, but when adding a new association table to your user object, the changes won’t take effect for your logged in profile until you log out if the damned user object is attached to the session…

I blame the Nyquil-clone. Or maybe I need a recharge.

Rails

Comments (0)

Permalink

Plesk Capistrano, and Mongrel: a love story

After 2 days of off and on server admin, I’ve finally got a production server that can take Capistrano deployments without sacrificing the Plesk GUI!

Here are some of the highlights - most of the steps I used can be found in Time for a Grown-Up Server, so this is more of a list of gotchas to do with a Plesk setup. I’m sure I’m missing a thing or two here and there, so contact me if you’re stuck and I’ll either fill in the blanks or fix my typos. :)

Installing Apache 2.2

Capistrano’s cool by itself, but if I’m messing around with server crap, I want a Mongrel cluster at the same time. While Plesk 8.1 supports Ruby on Rails via FastCGI, Capistrano seems to work best with Mongrel, and more importantly, that’s how I’ve got another server configured, so I’d rather have a smaller set of problems to troubleshoot between the boxes.

Unfortunately, running a cluster requires mod_proxy_balancer on Apache, which isn’t available until Apache 2.2. Plesk comes with Apache 2.0. Urgh.

Upgrading requires a few steps. I used Bryan Thompson’s guide to get Apache in, but it turned out I needed to compile it with –enable-openssl. Once that was in, I had to figure out how to handle the server config. Plesk likes to overwrite /etc/httpd/conf/httpd.conf a lot, and it keeps its virtual server config info (with other files) in /etc/httpd/conf.d. I didn’t care much about the non-virtual stuff - I can set that up myself, so I kept httpd.conf in its new /usr/local/apache2/conf directory and added an Include /etc/httpd/conf.d/zz010_psa_httpd.conf to keep the one file I wanted in play. I also had to include mod_suexec to keep everything happy.

Mongrel and Capistrano

Using the ultimate Time for a Grown-Up Server guide, I was able to get Mongrel and Capistrano working. The catch was getting Plesk to be happy with it.

Your mileage may vary, but my Plesk-managed websites were located at /var/www/vhosts/[site name]/httpdocs. I wanted the document root to be [app base]/current/public, so I switched it over with a symlink - I added a directory at /var/www/vhosts/[site name]/website and made that my base directory for Capistrano. Then I deleted (OK, renamed) httpdocs, and once I ran cap setup to get the rest of the structure in place, I did an ln -s /var/www/vhosts/[site name]/website/current /var/www/vhosts/[site name]/httpdocs to line everything up.

That gave me a 403 error, because Plesk was set up to not follow symbolic links. Chowning and chgrp’ing the new httpdocs probably fixed that.

Finally, it’s good to test a reboot to make sure everything sticks. Sure enough, when I tried to access my site I got a 503 error. The Mongrel processes hadn’t started. Thankfully The Google had my back and this post pointed a possible problem (boot path issues), but the fix didn’t work for me - at first. Since I didn’t have console access, I redirected the outputs of the commands in /etc/init.d/mongrel_cluster and it turned out I was running a different version of ruby in /usr/bin that didn’t have rubygems installed. Updating that version did the trick.

So here I am - now I can develop wherever I want, check in my code, and deploy to production without ever touching the live web directory, but I can still use Plesk to manage the occasional little server thing that I don’t want to bother remembering, though granted, the more tasks like this that I do, the less I need Plesk for.

Technorati Tags: , , , ,

Rails
Apache

Comments (5)

Permalink

Fixing up SaltedHashLoginGenerator

Note to self: using Ruby On Rails’ SaltedHashLoginGenerator is a lot easier with the following line added to user_controller below the class declaration:

before_filter :login_required, :only => [:welcome, :change_password]

Without that, the thing seems to want to authenticate everything, even account validation clicks from an email, which you’re obviously not logged in for.

Technorati Tags: , SaltedHashLoginGenerator

Rails

Comments (0)

Permalink

Dreamhost, Typo, and FastCGI

I spent far too much of this morning futzing about trying to get Typo working in a DreamHost account (no, it’s not public yet). This post turned out to be the key to getting everyting going.

While Typo is pretty sweet, I’m not sure if I’ll be able to actually use it with DH on a shared plan - I already get regular messages saying I blew the CPU limit, and right now I’ve got 5 instances of dispatch.fcgi that’ve sucked back 3 seconds of power each. Unfortunately, while DH has been great, and I still heartily recommend them for smaller sites (no, this blog isn’t the “problem”), they won’t have any dedicated servers available until they migrate their data centre.

Of course, I do have a static IP at home… While I wouldn’t want to run anything mission critical1 on it, a home server might be just the ticket for lower-traffic sites and experiments. Now if I could just get FastCGI working on Tiger…

  1. When I say things like that, it usually means I’ll be living the exact opposite within a year. Expect VP to be running from my desk by July… :)

Rails

Comments (1)

Permalink