Capistrano rules

Saturday, May 17, 2008

I’ve grown tired of committing changes to my subversion repository, logging into my server, updating my live checkout, and restarting python processes. I finally decided to implement Capistrano and eliminate this repetition.

Here are my repetitive set of commands:

$ ssh playgroundblues.com
$ cd ~/projects/playgroundblues
$ svn up
$ cd ~/www/playgroundblues.com/www
$ touch django.fcgi

Now, with the help of Capistrano, I just type:

$ cap deploy

You’ll first need to install Capistrano which is as simple as gem install -y capistrano. Once that’s complete you need to create a “capfile” which is where you’ll define your tasks:

task :deploy, :hosts => "username@playgroundblues.com" do
  run "cd ~/projects/playgroundblues; svn up; cd ~/www/playgroundblues.com/www/; touch django.fcgi"
end

The above will vary depending on your host and directory setup. After you save the above file and as long as you’re in the directory where the capfile resides you can, in the terminal, type cap deploy and Capistrano does the rest. Bliss.