A collection of useful utilities for Capistrano deployments
Installation Add this line to your application's Gemfile: gem 'capistrano', '~> 3.0' gem 'capistrano-maintenance', '~> 1.0' Add this line to you application's Capfile: require 'capistrano/maintenance'
...will make your application web-accessible again. Manual steps If you are still on capistrano 1, you can enable and disable the maintenance page manually. First, prepare a maintenance.html, for...
Capistrano has the concept of a "rollback" that comes in really handy in case of errors. When you notice that your recent deploy was faulty, run cap deploy:rollback and...
...re back with the previous release. In case of an error during a deployment, Capistrano will rollback itself. But, you may ask, how can it know how to revert all...
Capistrano 2 brings the shell command which allows you to run commands on your deployment targets. There is also invoke to run a command directly from your terminal.
...allow running Capistrano tasks or shell commands, and scope to individual machines or machine roles. Unfortunately Capistrano 3 does not include these commands any more. cap shell Basics
...way to do this: the HOSTFILTER env variable. Commenting out "server" lines in the Capistrano deploy config will raise a Capistrano::NoMatchingServersError with is only run for servers matching {:roles...
...matched. Instead, specify the server-under-test like this: HOSTFILTER=separate-sidekiq.makandra.de cap production deploy Capistrano is aware of this env variable and will only deploy that single server, skipping any...
You are getting when connecting via SSH or deploying with Capistrano (which uses SSH): Too many authentication failures for username This is caused by having too many SSH keys added...
...involves you keeping many keys will cause you pain. Painful fix for SSH and Capistrano: Add keys manually You will need to disable your gnome keyring daemon to regain control...
When deploying with capistrano it's possible you get this "error" message: *** [err :: example.com] There are no Phusion Passenger-served applications running whose paths begin with '/var/www/example.com'. *** [err :: example.com]
...this error, the configuration option --ignore-app-not-running is not set. We recommend using capistrano-passenger which has this option set as default. See How to let passenger restart...
Geordi now has a script that runs capistrano with all known deploy targets (i.e. staging, production…). Use with geordi capistrano deploy:migrations or geordi capistrano deploy The abbrevation geordi cap...
# do crazy stuff end end Whenever we call foo.bar in our recipe, Capistrano will fail if you deploy to a stage where none of the servers has the...
...a roles[:something] into your deploy.rb to avoid the above error message.\ Now, when Capistrano enters a hook and tries to call a method that is only available for that...
You can seriously speed up deployments with Capistrano when using a local git repository on the server you are deploying to. Simply add set :deploy_via, :remote_cache
...exclude, [ '.git' ] to your config/deploy.rb and Capistrano will create a clone in shared/cached-copy. This will be updated using git pull when deploying which transfers less bytes and is usually much...
Capistrano automatically logs each (successful) deployment into a file on your application servers. It is located at the root of your server's project folder, i.e. the parent of releases...
...currently deployed revision, we also have a card on this. It also contains a Capistrano task that can be called from developer machines...
...are stored per server (unless you choose a centralized logging solution). Here is a Capistrano task that connects to all servers and prints logs to your terminal like this:
...use the LOG env variable, like LOG=sidekiq cap production app:logs. Note that Capistrano truncates lines that are longer than your terminal. This can be painful when looking at...
By default, Capistrano truncates server responses and places an ellipsis at the end of lines that are longer than your terminal. Error messages are never truncated. While this can be...
...knowing what is going on, even if causes a few extra lines of output. Capistrano by default uses Airbrussh which is where truncation happens. To disable truncation globally, place this...
Given you use Capistrano together with bundler to automatically install your gems when deploying. I recently had the problem that Capistrano stalled like this: [err :: host.name.tld] Username:
...connect to the server in order to e.g. access the production console. Guessing the Capistrano deploy user and then again guessing the right directory on the server is awkward, so...
...handy command shell-for. Run it from any project directory like this, passing a Capistrano multistage deployment target: shell-for staging Now it also supports commands to be remotely executed...
...track production deploys within the commit history. This task does the tagging for you. Capistrano 3 # lib/capistrano/tasks/deploy.rb namespace :deploy do ... desc 'Tag the deployed revision' task :tag_revision do
Capistrano is by default configured to exclude the gems of the groups development and test when deploying to the stages production and staging. Whenever you create custom groups in your...
There is a conflict between current capistrano versions and the 2.5.1 net-ssh gem. Make sure you upgrade to 2.5.2, then it should work again...
Attached is a working config to deploy an application with Capistrano that needs to monitor Resque workers with God. God will run as the deployment user, no need to register...
...script is relying on. Run it from any project directory like this, passing a Capistrano multistage deployment target: console-for staging This script is part of our geordi gem on...
...and run all pending migrations before restarting it, you can use the following standard Capistrano task: cap deploy:migrations Little is known what happens when the deployment goes through, but...
In order to bring up a textual description of a Capistrano task you can say cap -e taskname ... where taskname is the name of the task you're not sure...
Sometimes, through some firewall or proxy misconfiguration, you might have to deploy to a server that cannot access the git...
I got these warnings while deploying a Rails 3.2 app with asset pipeline enabled: *** [err :: host.tld] find: `/opt/www/hollyapp.com/releases/20120503115342/public/images': No such...