...configured accordingly. 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'
...page is enabled while a user interacts. Manual steps If you are still on capistrano 1, you can enable and disable the maintenance page manually. First, prepare a maintenance.html, for...
When deploying, Capistrano puts a REVISION file into your application's release directory. It contains the hash of the commit which was deployed. If you want to know the currently...
...deployed release, simply SSH to a server and view that file. $ cat /var/www/my-project/current/REVISION cf8734ece3938fc67262ad5e0d4336f820689307 Capistrano task When your application is deployed to multiple servers, you probably want to see a...
...restart-app /path/to/app You should not need to know which one to use. Instead, the capistrano-passenger gem will choose the appropriate restart mechanism automatically based on your installed the...
...passenger version. Installation Add to your Gemfile: gem 'capistrano-passenger', require: false Add to your Capfile: require 'capistrano/passenger' Declare which server role should be restarted (optional). Usually passenger tries to...
...are sensitive and must not be stored on your machine. Instead, put the attached capistrano task into lib/capistrano/tasks/ of your application. It expects environment specific keys to live in :shared...
...path/config/credentials/:stage.key. If you have a single master.key (e.g. on Rails < 7.2), edit the Capistrano task to find the key at :shared_path/config/master.key instead. Usage cap credentials:edit
In Capistrano 3, your Capfile requires 'capistrano/rails/migrations', which brings two Capistrano tasks: deploy:migrate and deploy:migrating. The former checks whether migrations should be performed. If so, the latter is...
You can hook into Slack when using Capistrano for deployment. The slackistrano gem does most of the heavy lifting for you. Its default messages are unobtrusive and can be adjusted...
...it posts to a Slack channel like this: How to integrate Integrating Slackistrano with Capistrano 3 is fairly simple. If you are not a Slack admin Find a Slack workspace...
Remember How to skip Sprockets asset compile during Capistrano deployment and Automatically skipping asset compilation when assets have not changed? Turns out there is an even better way to speed...
...up Capistrano deployments with asset compilation – and it's even simpler. Adding the asset cache directory to symlinked directories Popular asset managers for Rails are Sprockets and Webpacker. Both keep...
Capistrano is quite verbose during deploy. In practice, almost all of its output is noise to me. It would be much more helpful if showed me an overview of total...
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...
...only cleans up releases, not assets. In order to clean up assets, you can use capistrano-rails. Just require 'capistrano/rails' in Capfile and add the following config: # config/deploy.rb
...asset and remove any older versions. If you are using Webpacker, you need to configure capistrano-rails. If you are on Rails 3, you cannot use this to clean up...
...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 3 has a doctor task that will print information about Environment: Ruby, Rubygems and Bundler versions List of Capistrano gems and whether an update is available All config variables...
...and their values Capistrano server config $ bundle exec cap staging doctor
Using Capistrano, we usually have some array configurations in the config/deploy.rb file, like set :linked_files, %w[config/database.yml], so in this case we don't have to manage the database...
...but not every deploy target has this feature activated. Here comes a nice handy Capistrano feature, which lets us modify the default configuration for individual environments, instead of copying the...
...using Webpacker and Capistrano, there are a few configuration tweaks that optimize the experience. Using capistrano-rails capistrano-rails is a Gem that adds Rails specifics to Capistrano, i.e. support...
...here, but add the Webpacker cache dir (see link below) set :linked_dirs, %w[… tmp/cache/webpacker] # capistrano-rails config set :assets_roles, %i[webpack] # Give the webpack role to a single...
This Capistrano task runs a command on all servers. bundle exec cap production app:run cmd='zgrep -P "..." RAILS_ROOT/log/production.log' Code # lib/capistrano/tasks/app.rake namespace :app do # Use e.g. to grep logs...
end else puts 'x Canceled.' end end Make sure you require custom Capistrano task files: # Capfile Dir.glob('lib/capistrano/tasks/*.rake').each do |r| # `import r` calls Rake.application.add_import(r...
...please ensure you use version 5.2.0 or newer to ensure you can deploy via Capistrano. It's best to use the latest version, as there were multiple issues between...
Whenever requires you to set the application attribute in your Capistrano configuration. Otherwise your cronjobs are created multiple times. Example entry in config/deploy.rb: set :application, 'some-app' # allows "set :whenever...
...to install some tasks only for a given Rails environment or for a given Capistrano stage ("deployment target"). Installing jobs only for a given Rails environment In your schedule.rb you...
...environment=staging bundle exec whenever --set environment=production Installing jobs only for a given Capistrano stage In some apps we have custom capistrano stages like this: customer1-staging customer1-production...
...unset LD_PRELOAD bundle exec rake asset:precompile To permanently set this option in capistrano edit config/deploy.rb: # Disable Jemalloc for asset:precompile task set :default_env, { 'LD_PRELOAD...
...for a Rake task within a Rails app to depend on :environment. Understand that Capistrano tasks are also defined using the Rake DSL, but a Capistrano task is not automatically...
...algorithm instead of RSA (see Create a new SSH key pair), the deployment with Capistrano may fail with the following message: The deploy has failed with an error: unsupported key...
gem 'bootstrap-sass' # If you want to use Bootstrap gem 'byebug' gem 'capistrano' gem 'capistrano-middleman', require: false config.rb activate :livereload activate :sprockets configure :build do activate :minify_css...
...Rails'ish webserver is already configured to deliver from. Note that you must not require capistrano-middleman manually, although stated in the gem's README. Doing so would screw the...
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'
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...