12.4. Summary

Deployment can be the scariest time in the lifecycle of your Rails application. Too often you are forced to be manual when you most need to be automatic. Capistrano is the predominant Rails tool for supporting automated and repeatable deployment.

Capistrano assumes certain features of your deployment. It expects to be able to communicate with the server via SSH, specifically using public keys. To get the most use out of Capistrano, use source control, preferably Subversion.

Capistrano enables you to split your servers into different roles and allows different tasks to be applied to all servers in the specified roles. There are several different tasks predefined by Capistrano to support the most common deployment and rollback tasks. In most cases, you'll need to customize somewhat to make sure that the scripts match your web server setup.

If those tasks are not enough, you can write your own tasks using a Ruby syntax that is very similar to Rake, although dependencies among tasks are managed differently. Capistrano can also handle the common case where there is a staging server that mimics the production environment.

Mongrel is the current best-of-breed Ruby web server for serving Rails applications. It can easily be integrated with Capistrano. However, Mongrel is single-threaded, so in production environments it is run in a cluster. Load balancing is handled by a proxy, of which Pen is a simple example and Apache is a more complex example. Apache can also be configured ...

Get Professional Ruby on Rails™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.