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.
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.
I personally use in production a helper method like this:
That allows to run rake task similar to using the run (command) method.
NOTE: It is similar to what Duke proposed, but I:
Use Capistrano-style rake invocations
There's a common way that'll "just work" with
require 'bundler/capistrano'
and other extensions that modify rake. This will also work with pre-production environments if you're using multistage. The gist? Use config vars if you can.Capistrano 3 Generic Version (run any rake task)
Building a generic version of Mirek Rusin's answer:
Example usage:
cap staging "invoke[db:migrate]"
Note that
deploy:set_rails_env
requires comes from the capistrano-rails gem