Whenever requires you to set the application attribute in the Capistrano config

Updated . Posted . Visible to the public.

Whenever requires you to set the application attribute in your Capistrano configuration Show archive.org snapshot . Otherwise your cronjobs are created multiple times.

Example entry in config/deploy.rb:

set :application, 'some-app' # allows "set :whenever_identifier, ->{ "#{fetch(:application)}_#{fetch(:stage)}" }" to work as expected

Good

Then the crontab -l output will look like this:

# Begin Whenever generated tasks for: some-app_staging

34 23 * * * /bin/bash -l -c 'cd /var/www/some-app_staging/releases/20201215171150 && RAILS_ENV=staging bundle exec rake some-task'

# End Whenever generated tasks for: some-app_staging

Bad

Instead of a non unique identifier with the default value, that can not be replaced by Whenever (the release folder changes every deploy):

# Begin Whenever generated tasks for: /var/www/some-app_staging/releases/20201215171150

34 23 * * * /bin/bash -l -c 'cd /var/www/some-app_staging/releases/20201215171150 && RAILS_ENV=staging bundle exec rake some-task'

# End Whenever generated tasks for: /var/www/some-app_staging/releases/20201215171150

# Begin Whenever generated tasks for: /var/www/some-app_staging/releases/20201215171000

34 23 * * * /bin/bash -l -c 'cd /var/www/some-app_staging/releases/20201215171000 && RAILS_ENV=staging bundle exec rake some-task'

# End Whenever generated tasks for: /var/www/some-app_staging/releases/20201215171000
Last edit
Michael Leimstädtner
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2020-12-16 13:22)