Skip to content

Instantly share code, notes, and snippets.

@dstrelau
Created February 15, 2010 17:13
Show Gist options
  • Save dstrelau/304800 to your computer and use it in GitHub Desktop.
Save dstrelau/304800 to your computer and use it in GitHub Desktop.
namespace :deploy do
namespace :crontab do
def update_cmd_for(role)
load_file = "config/whenever/#{fetch(:environment)}.#{role}.rb"
[ "cd #{fetch(:current_path)} &&",
"if [ -f #{load_file} ] ; then",
"bin/whenever",
"--update-crontab #{fetch(:application)}.#{fetch(:environment)}.#{role}",
"--load-file #{load_file}",
"--set environment=#{fetch(:environment)}",
"; fi"
].join(' ')
end
desc "Update the crontab files by running 'whenever'"
task :update do
parallel do |session|
roles.keys.each do |role|
session.when "in?(#{role.inspect})", update_cmd_for(role)
end
end
end
end
end
after "deploy:update", "deploy:crontab:update"
every 10.minutes do
rake "ts:index"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment