Skipping Asset Compilation with Capistrano

13 December 2011

Capistrano has a handy task that runs rake assets:precompile for you when you are deploying your Rails 3.1 application. This gives you an easy way to get the performance boosts of having only one css file and one javascript file to load per request. The price you pay for that benefit is the amount of time it takes to run that rake task when you are deploying. There is a way to get the benefit while reducing that cost, though.

Since capistrano creates a symlink for the assets that is moved across deploys, you really don't need to compile those assets for any deploy where the assets didn't change. Instead, all you need to do is move the symlink. However, the default capistrano for compiling the assets does compile them every time, regardless of whether any assets were changed in the set of commits that you are deploying. The trick, then, is to check the list of files that were changed in the range of commits that are being deployed, and compile the assets only if assets show up in that list. And here is a code snippet that does exactly that:

It only supports git, as that's what I use, so if you use git, just drop that snippet into deploy.rb and enjoy quicker deployments.



Deploying New Relic Server Monitoring with Chef

08 December 2011

This morning I deployed New Relic's new Server Monitoring feature for the first time (I've used Scout previously). It's cool to see your server vitals right next to all your app vitals, and their interface looks attractive, to boot.

Since I deploy everything with Chef, I threw together a quick Chef recipe to automate the installation of New Relic's server monitoring agent. It has been tested with Ubuntu 10.04 LTS, and you can configure the license key in your Chef JSON config.

You can grab the recipe from my Chef recipe repository at Github.



CentOS 5.5 net install secret

09 September 2011

Today I needed to spin up a VM with CentOS 5.5. My preferred distro these days is Ubuntu, and I had to learn the CentOS dance to get an unsupported version installed, so it took me a little longer than I would have liked to get it going. Here's the secret:

When asked for the name and directory of the install image, enter vault.centos.org for the name and 5.5/os/x86_64 for the directory. If that doesn't work for you, go back a step and disable IPv6. After that, you should be good to go.



Chef Tips

25 May 2011

One of the best things that came out of using EngineYard Cloud was learning about Chef. Chef has changed my world when it comes to managing servers, and I now wouldn't do any amount of system administration without the kind of automation and scriptability Chef provides. Here are a couple of tips on the reasons for and the benefits of using Chef.

Read the rest of this entry »



Auto-spawning Delayed Job Workers

12 April 2011

I've been interested in simplifying lately.... using Chef (solo) to configure boxes, switching to Postgres from MySQL to get decent text search without having to run sphinx, etc. My goal recently has been to cut down the number of moving parts in my deployments to make my life a little easier. So when a client project required background processing, I re-evaluated my stock approach to see if I could simplify a bit.

Read the rest of this entry »