Capistrano: Delete old releases automatically
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 5 releases in case you need to rollback to an older release. You can overwrite this setting by using
set :keep_releases, 3
Related cards:
Howto: Free disk space when /boot is full
Easy mode
This method will remove automatically installed packages that no other packages depend on any more. This, of course, includes obsolete kernel versions, with the explicit exception of the currently running kernel, the kernel version th...
Capistrano + Rails: Automatically skipping asset compilation when assets have not changed
In medium-sized to large Rails applications, asset compilation can take several minutes. In order to speed up deployment, asset precompilation can be skipped. This card automates the process.
Capistrano 3
namespace :de...
Git: How to automatically stage deleted files for commit
When you do a git add .
and have deleted files, git won’t stage them to be commited (as deleted). Use
git add -u
From the git documentation: -u
, --update <filepattern>
Only match against already tracked files in the ...
Upgrading from Capistrano 2 to 3
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 and use Rake
instead. For connecting with and operating on the ...
Capistrano: Finding out who deployed which revision of your application and when
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
and current
, like so:
/var/www/your-project$ ls
cu...
Configuring Webpacker deployments with Capistrano
When deploying a Rails application that is using Webpacker and Capistrano, there are a few configuration tweaks that optimize the experience.
Using capistrano-rails
capistrano-rails is a Gem that adds R...
Outlook deletes iCalendar ICS eMails and moves them to trash folder
We sometimes send calender data or tasks using iCalendar (ICS) via eMail as specified in RFC 5545.
Recently, a customer noticed that Outlook automatically moved eMails containing such ICS data to deleted item...
How to let passenger restart after deployment with capistrano
Phusion Passenger changed the way how it gets restarted several times. Through the project's history, these all were valid:
touch tmp/restart.txt
sudo passenger-config restart-app /path/to/app
-
passenger-config restart-app /path/to/app
...
Clean up application servers when deploying
Our development process makes us deploy very often. As the number of releases grows, junk clogs up the hard drive of our application servers:
- Old release code
- Old
tmp
folders with compiled view templates etc. - Precompiled assets (Javascrip...
Bundle capistrano
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 this:
# Gemfile
group :deploy do
gem 'capis...