Jorge de los Santos
Jorge de los Santos

Reputation: 4633

How to define and run capistrano 3 task after deploy?

I have a capistrano script that works perfect, except it's not running a task after the deploy. I'm using rails_daemons to launch the rails application and a I need to restart the daemons.

#deploy.rb

namespace :deploy do
  on roles :all do
    execute :bundle, "exec rake daemons:restart"
  end
end

Tryed this also:

task :restart_daemons, :roles => :app do
  execute :bundle, "exec rake daemons:restart"
end

after "deploy", "deploy:restart_daemons" 

Upvotes: 3

Views: 2714

Answers (2)

Moxorama
Moxorama

Reputation: 31

I'm using this one (Rails 7/Capistrano 3)

In config/deploy/production.rb

namespace :deploy do
  desc 'sitemap.xml refresh'
  task :sitemap_refresh do
    on roles(:app) do
      within current_path do
        with rails_env: fetch(:rails_env) do
          execute :rake, 'sitemap:refresh'
        end
      end
    end
  end

  after 'deploy', 'deploy:sitemap_refresh'
end

Upvotes: 2

davids
davids

Reputation: 6371

First off, have you checked if bundle exec rake daemons:restart works locally? If so, try something like this:

namespace :deploy do

  after :restart do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      within release_path do
         execute :rake, 'daemons:restart'
      end
    end
  end

end

Upvotes: 3

Related Questions