Created
May 30, 2012 01:29
-
-
Save kyamaguchi/2832280 to your computer and use it in GitHub Desktop.
Capistrano rake recipes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [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