Capistrano : A Brief Introduction

Capistrano is a Ruby gem designed to execute tasks on one or more remote machines. You’ll need SSH access to use Capistrano. Capistrano, affectionately known as Cap, automates the deploy process. We can use cap to take our code from some a repo and push it to the server, stop/start/restart the server, write custom tasks required by our application (think install required gems), or disable/enable a maintenance page. Using cap is not required but it sure beats using FTP to copy all the files around! Cap’s real power comes from the ability to write custom tasks in Ruby to manipulate the server.

We’ve written a lot of applications that allow user file uploads. Then on the server side, some directory needs to be created with proper permissions for the uploads to succeed. It’s easy enough to write a cap task to create the directory and set the permissions. Then, if you ever change servers, you can simply run the cap task to setup the server again. There are many things you can do with Capistrano.
As its Rails deployments became more regular and more complex, the growing company needed an automated solution to handle complex application deployments. This typically entailed deploying code updates to at least two web servers and one database server. Any solution would need to do at least the following:

• Securely update multiple web and database servers from a central source code control repository.
• Be sensitive to errors, and roll back any changes if necessary.
• Work with the Rails file layout and allow logging to happen without interruption.
• Operate quickly and reduce the need for downtime.
• Work well with Ruby on Rails.


Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Difference between Validations, Callbacks and Observers