部署后如何定义和 运行 capistrano 3 任务?

How to define and run capistrano 3 task after deploy?

我有一个运行完美的 capistrano 脚本,除了它不是 运行 部署后的任务。我正在使用 rails_daemons 启动 rails 应用程序,我需要重新启动守护进程。

#deploy.rb

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

也试过这个:

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

after "deploy", "deploy:restart_daemons" 

首先,您是否检查过 bundle exec rake daemons:restart 是否在本地工作?如果是这样,请尝试这样的操作:

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