Skip to content

Instantly share code, notes, and snippets.

@jherdman
Created November 4, 2010 15:53
Show Gist options
  • Save jherdman/662678 to your computer and use it in GitHub Desktop.
Save jherdman/662678 to your computer and use it in GitHub Desktop.
require 'whenever/capistrano'
##
# Force Whenever to use the Capistrano stage. We use a lambda to delay execution
# until absolutely necessary.
set :whenever_command, lambda { "whenever --set environment=#{fetch(:stage, 'production')}" }
@phillmv
Copy link

phillmv commented Nov 4, 2010

We added it to our bundler, and the following task can be found in our common.rb

desc "Set up cron jobs for this release"
task :setup_crontab do
run "cd #{current_release} && whenever --update-crontab comments"
end

@jherdman
Copy link
Author

jherdman commented Nov 4, 2010

Whenever actually comes with a very similar, and configurable, Capistrano task. What I'm doing in my gist is modifying their setting for the "whenever" executable so that it dynamically sets the environment to use based on the current Capistrano environment used (e.g. staging, dev, production).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment