makandra dev
semaphoreci.com

Capistrano 3 is a major rework of the framework and requires several adjustments to your deploy configuration files. The biggest change is that they moved away from their custom DSL...

Step 1: Upgrade guide For migration from 2 to 3, follow this tutorial: Capistrano 3 Upgrade Guide. Step 2: More changes Task syntax has changed. desc 'Run script'

Whenever you deploy using Capistrano, a new folder is created within the releases directory on the remote server containing the application code. By default Capistrano 3 keeps the last...

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...

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...

...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...

In Capistrano 2, directories in shared_children used to be symlinked to the shared directory during the finalize_update task. # /lib/capistrano/recipes/deploy.rb _cset :shared_children, %w(public/system log tmp/pids) # ... task :finalize...

...symlinks only the last segment here end # ... end This would symlink current/public/system to shared/system. Capistrano 3 (which is almost a complete rewrite of the project) now properly expands paths to...

# 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...

After updating your RubyGems, you will probably not be able to run Capistrano any more, but receive an error similar to this: can't activate net-ssh (= 2.0.22) for [], already...

...other sensible place), that only contains these 2 lines: source 'http://rubygems.org' gem 'capistrano' gem 'capistrano-ext' # You need this for multistage deployments gem 'hoptoad_notifier' # Add this for projects...

...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...

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...

...requests should be stored in public/system. Execute assets:precompile only on one server with Capistrano 3 If the assets directory is linked to glusterfs asset:precompile should only be executed...

...role web. You can overwrite this in deploy.rb: set :assets_roles, [:assets] This tells Capistrano that only the role :assets should precompile assets. Now you need to add the :assets...

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...

makandra dev

Capistrano recently had some API changes that can results in deploys not working when running with old deploy.rb files. So let's bundle it. Put capistrano into your Gemfile, like...

# Gemfile group :deploy do gem 'capistrano' gem 'capistrano_colors' end It's possible you need to do a bundle update net-ssh to get things running. Now double check...

makandra dev

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...

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...

...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...

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:

opensoul.org

Sometimes, you just need to shoot from the hip…or deploy your local changes without committing them. Put this snippet...

...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...

Sometimes, through some firewall or proxy misconfiguration, you might have to deploy to a server that cannot access the git...

...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

...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...

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...