How do I run a rake task from Capistrano?

I already have a deploy.rb that can deploy my app on my production server.

My app contains a custom rake task (a .rake file in the lib/tasks directory).

I'd like to create a cap task that will remotely run that rake task.

Answers


a little bit more explicit: in your \config\deploy.rb, add outside any task or namespace:

namespace :rake do  
  desc "Run a task on a remote server."  
  # run like: cap staging rake:invoke task=a_certain_task  
  task :invoke do  
    run("cd #{deploy_to}/current; /usr/bin/env rake #{ENV['task']} RAILS_ENV=#{rails_env}")  
  end  
end

Then, from /rails_root/, you can run:

cap staging rake:invoke task=rebuild_table_abc

Need Your Help

.Net 4. View consumed web service headers and body from request and response

c# wcf web-services header

We're consuming a web service (web reference, not service reference), and I need a way to output the entire message being sent (including headers) and the message that gets received.

How does ASP.NET determine whether to queue a request or not?

asp.net threadpool

When ASP.NET receives a request, how does it determine whether to serve it or to queue it? I ask because I'm monitoring performance counters on a server and the CPU is not maxed out and there are a

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.