ruby-on-rails 如何在部署后定义和运行capistrano 3任务?

yrwegjxp  于 2023-06-07  发布在  Ruby
关注(0)|答案(2)|浏览(120)

我有一个capistrano脚本,它工作得很好,除了它在部署后没有运行任务。我正在使用rails_daemons来启动rails应用程序,我需要重新启动守护进程。

  • #部署.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"
xbp102n0

xbp102n01#

首先,你有没有检查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
n3schb8v

n3schb8v2#

我正在使用这个(Rails 7/Capistrano 3)
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

相关问题