Deploying web apps and web sites is one of the more complicated and time consuming tasks that a web developer must endure. Typically, developers will have a number of machines in addition to their production server or servers. They may have a development server in the cloud or they may develop on their desktop or laptop machine. They will probably also have a staging server for testing new code before it’s pushed to production. Syncing up code between these servers manually is problematic and prone to mistakes, particularly if there are multiple development, staging, and production servers that need to be kept synchronized.
At the end of a busy day coding, it’s all to easy to push the wrong data to the wrong server, as an Azerbaijani developer recently discovered, probably to his detriment.
Automation is the best way to prevent error-prone repetitive tasks turning into a snafu, freeing up developer time for more productive jobs. While it is possible to draft tools like Puppet in to automate app deployment, that’s not really what they are designed for and they’re a little overpowered. Capistrano is a remote server automation tool that’s designed to make it easy to deploy apps and carry out other server automation tasks.
Capistrano, which is written in Ruby but can be used to automate other languages, is capable of deploying sites and apps to servers automatically according to pre-built recipes. A fairly trivial use of Capistrano would be with a static site generator like Jekyll. An aspect of Jekyll that puts many people off is having to upload the generated files with every change. With Capistrano that process can be automated, so that a site’s static files can be generated, securely uploaded, and deployed with a single command. Even better, Capistrano is capable of rolling back deployment to a previous state just as easily.
Capistrano also integrates well with Git and other version control systems, so if a site’s files are being managed in Git or on GitHub, it’s possible configure Capistrano to snag the files from the source control repo and deploy them to a server.
Capistrano is capable of much more than deployment: it can also be used for server auditing, log processing, application of updates, and automation of other common server maintenance tasks and workflows. Many of these automations can be linked together into complex workflows, so developers can automate a set or pre- and post-deployment actions.
Capistrano on GitHub
What is Capistrano? from the Capistrano documentation.
Are you using Capistrano for your deployments and server automation? Let us know how it’s working for you in the comments.