Read more

Capistrano 2: How to deploy a single server

Dominik Schöler
June 13, 2017Software engineer at makandra GmbH

When you have a multi-server setup, you'll be adding a new server from time to time. Before doing a full deploy, you might want to test that server in an isolated deploy. There is a single way to do this: the HOSTFILTER env variable.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Commenting out "server" lines in the Capistrano deploy config will raise a Capistrano::NoMatchingServersError with <task> is only run for servers matching {:roles=> <role>}, but no servers 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 tasks that do not apply. Profit!


As a side note, there is a secret Capistrano task option that will also silence the above exception. Generally it is a good idea that Capistrano complains when it doesn't have a server to run a (presumably important) task on. If you want it optional, define it like this:

task :my_task, on_no_matching_server: :continue do
  # Do stuff
end
Posted by Dominik Schöler to makandra dev (2017-06-13 17:35)