【问题标题】:Capistrano not restarting nginxCapistrano 没有重新启动 nginx
【发布时间】:2016-07-04 01:11:06
【问题描述】:

我已经设置了 Capistrano,一切工作正常,除了 Capistrano 在部署后没有重新启动乘客。部署后的 Eveytime 我必须通过 ssh 进入服务器并在 current directory 中输入 touch tmp/restart.txt。我尝试了不同的方法来重新启动乘客,但没有任何东西对我有用。

first attempt:

namespace :deploy do
  task :restart do
    on roles(:app) do
      run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
    end
  end
end

second attempt

namespace :deploy do
  task :restart do
    on roles(:app) do
      within current_path do
         execute :touch, 'tmp/restart.txt'
      end
    end
  end
end

third attempt

namespace :deploy do
  task :restart do
    run "touch #{current_path}/tmp/restart.txt"
  end
end

我在 stackoverflow 中发现上面的代码 sn-ps 与我的问题类似,但它们都没有重新启动服务器。

我正在使用 capistrano (3.4.0)Rails 4(nginx + 乘客)

【问题讨论】:

    标签: ruby-on-rails capistrano


    【解决方案1】:

    可能是您的deploy:restart 任务没有被执行。

    Capistrano 3.1.0 及更高版本(如Capistrano's CHANGELOG 中所述)不会在cap deploy 末尾自动执行deploy:restart

    因此,您必须明确告诉 Capistrano 这样做,将其添加到您的 deploy.rb

    after 'deploy:publishing', 'deploy:restart'
    

    【讨论】:

    • 嗨,马特,我的 deploy:restart 没有被执行。我将在下班后尝试您的建议,并会在晚上为您提供最新信息。谢谢
    猜你喜欢
    • 2016-11-08
    • 1970-01-01
    • 2012-08-09
    • 2010-12-07
    • 2020-03-18
    • 1970-01-01
    • 1970-01-01
    • 2011-03-01
    • 1970-01-01
    相关资源
    最近更新 更多