Skip to content

Instantly share code, notes, and snippets.

@kyamaguchi
Created May 30, 2012 01:29
Show Gist options
  • Save kyamaguchi/2832280 to your computer and use it in GitHub Desktop.
Save kyamaguchi/2832280 to your computer and use it in GitHub Desktop.
Capistrano rake recipes
# [NOTE!] namespace :rake cannot be used because 'rake' is already used as capistrano variable.
# #{rake} will be #<Capistrano::Configuration::Namespaces::Namespace:0x103abdf48> and command will abort if namespace :rake is used.
namespace :raketask do
desc "Show available rake tasks($ cap staging raketask:show_tasks)."
task :show_tasks do
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} -T"
end
desc "Run a task on a remote server($ cap staging raketask:invoke task=a_certain_task)."
# run like: cap staging raketask:invoke task=a_certain_task
task :invoke do
run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{ENV['task']}"
end
desc "Test to run a task on a remote server($ cap staging raketask:test_invoke task=about)."
# run like: cap staging raketask:test_invoke task=about
task :test_invoke do
cmd = "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{ENV['task']}"
puts "'$ cap staging raketask:invoke task=#{ENV['task']}' will run next command on remote servers.\n#{cmd}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment