The first session I attended was Intro to Capistrano presented by Mike Clark. Capistrano, formerly known as SwitchTower, is a ruby gem that makes deploying web applications dead simple. It was written by Jamis Buck who, unfortunately, wasn't there today. Capistrano works great with Rails, but its usefulness isn't limited to just Rails. Mike's presentation was great and covered the steps for setting up "cap" from the install to configuration to first time deployment to revision deployments to custom tasks for doing other things. I haven't had a chance to use cap yet, but after hearing Mike's presentation it's on my list of "things I have to use". Here are my unedited notes from the session:
Install Cap:
gem install capistrano
Setup with your App:
cap --apply-to /path/to/my/app MyAppName
Recipe file holds the information
Names of serves and Roles. app, web, and db are predefined roles.
There is a concept of a primary server.
where the deployed code goes:
set :deploy_to "/library/rails/#{application}"
Now you need a deploy target. This sets up every server you have configured in the recipe.
cap setup
First time to deploy:
cap update_code symlink
That will do a svn co (if you're using svn) on every machine with a role.
Now when there is a new release read:
cap deploy
To revert a deployment:
cap rollback
You can rollback multiple times to previous versions.
Other commands:
cap disable_web
cap enable_web
This puts up a maintenance screen. If you're running multiple web servers and you need to update the database with migrations or something.
cap diff_from_last_deploy
You can set up your own tasks. You can set them to run only on machines with a certain role.
You can chain multiple tasks together.
Set up channels and streams. This is good because you can use it to tail the log files on the servers.
Task hooks. Run something before or after another task runs (like deployment).
Use it for multiple configurations like development, production, and test.
A great example of this are libraries for cap.
gem install capistrano-ext
This particular one outputs load information. This library is good to look at to learn how to write capistrano extensions.
Capistrano Assumes:
remote servers talk POSIX
same deploy directory structure and password on each machine
web app uses FastCGI with Apache or LightTPD
*it's easy to make this work with mongrel
Technorati Tags: RailsConf, Capistrano, Ruby on Rails
Comments