Yui
Yui

Reputation: 74

Run Raketask after capistrano deployment

How is it possible to run a rake task after the deployment has been finished?

I tried the following:

namespace :add_records do
  desc "Run a task on a remote server."
    task :default do
  run("cd #{deploy_to}/current; /usr/bin/env bundle exec rake my_task_group:test_records RAILS_ENV=#{rails_env}")
end 

The task gets executed during the deployment but results in an error. I know that the task must run right after and not during the deployment.

How to solve it?

Upvotes: 0

Views: 299

Answers (1)

Jakub Jatczak
Jakub Jatczak

Reputation: 71

Run it after last step of deployment, in your deploy.rb:

after :last_task_in_deploy, :task_you_want_to_run

If it is sufficient that deployment is finished, and server does not need to be restarted, run after :publish

  after :publish, :task_you_want_to_run

Upvotes: 1

Related Questions