Advertisement
Guest User

How do I run a rake task from Capistrano

a guest
Feb 28th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. run("cd #{deploy_to}/current && /usr/bin/env rake `<task_name>` RAILS_ENV=production")`
  2.  
  3. namespace :rake do
  4. desc "Run a task on a remote server."
  5. # run like: cap staging rake:invoke task=a_certain_task
  6. task :invoke do
  7. run("cd #{deploy_to}/current; /usr/bin/env rake #{ENV['task']} RAILS_ENV=#{rails_env}")
  8. end
  9. end
  10.  
  11. cap staging rake:invoke task=rebuild_table_abc
  12.  
  13. def run_rake(task, options={}, &block)
  14. command = "cd #{latest_release} && /usr/bin/env bundle exec rake #{task}"
  15. run(command, options, &block)
  16. end
  17.  
  18. def rake(cmd, options={}, &block)
  19. command = "cd #{current_release} && /usr/bin/env bundle exec rake #{cmd} RAILS_ENV=#{rails_env}"
  20. run(command, options, &block)
  21. end
  22.  
  23. rake 'app:compile:jammit'
  24.  
  25. run("cd #{release_path}/current && /usr/bin/rake <rake_task_name>", :env => {'RAILS_ENV' => rails_env})
  26.  
  27. Rake::Task["task:name"].invoke
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement