【问题标题】:Capistrano: "cap deploy" doesn't take effect when deploying a Rails applicationCapistrano:部署 Rails 应用程序时“cap deploy”不生效
【发布时间】:2012-03-11 17:26:46
【问题描述】:

我正在使用 Capistrano 部署我的 Rails 应用程序。 一旦我对我的应用程序进行了更改,我就会执行“cap deploy”并且它似乎工作正常,但更改不会生效。我总是要做“cap deploy:stop”和“cap deploy:start”,然后一切都很好。 所以我想这与部署更改时运行的“cap deploy:restart”有关。

这是我的 deploy.rb:deploy.rb gist

希望有人能提供帮助。

提前谢谢你

【问题讨论】:

  • 您能否进行完整的部署并将输出通过管道传输到日志中,例如:cap deploy > deploy.log 2>&1
  • @PizzaPill 在这里:deploy.log

标签: ruby-on-rails deployment capistrano


【解决方案1】:

如果您使用USR2 信号重新启动独角兽,它不会自动知道捆绑器的正确环境。查看这个要点(特别是 before_exec 块)并相应地调整你的独角兽配置。

https://gist.github.com/534668

希望对您有所帮助。

【讨论】:

    【解决方案2】:

    刚刚在您的要点中注意到第 (105) 行

    task :restart, :except => { :no_release => true } do
      if File.exist?("/tmp/unicorn.example.pid")
        run "kill -s USR2 `cat /tmp/unicorn.example.pid`"
      end
    end
    

    您正在测试本地计算机上是否存在 pid 文件。相反,您应该在您的服务器上执行此操作。尝试将其更改为

    task :restart, :except => { :no_release => true } do
      run "test -f /tmp/unicorn.example.pid && kill -s USR2 `cat /tmp/unicorn.example.pid`"
    end
    

    但请记住,如果 pid 文件丢失,它仍然会静默失败。

    【讨论】:

    • 你确定这是在检查我本地机器上的文件存在吗?因为我刚从this tutorial 得到那个 deploy.rb 并认为一切都会好起来的......
    • 我做了那个改变,但我仍然需要做 cap deploy:stop 和 cap deploy:start :(
    • 请问可以直接在服务器上运行吗? kill -s USR2 cat /tmp/unicorn.example.pid
    • 我做了kill -s USR2 cat /tmp/unicorn.example.pid,它返回-bash: kill: cat: arguments must be process or job IDs -bash: kill: /tmp/unicorn.example.pid: arguments must be process or job IDs
    • 请在cat /tmp/unicorn.example.pid 周围添加引号作为答案。在这里引用正确的内容很难作为评论。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-30
    • 2019-04-27
    • 1970-01-01
    • 2014-01-16
    相关资源
    最近更新 更多