ruby-on-railsrubycapistrano3

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" 

Solution

  • 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