【问题标题】:Why does the Heroku Rails App crash after upgrading Rails to 6.0.0?为什么将 Rails 升级到 6.0.0 后 Heroku Rails 应用程序崩溃?
【发布时间】:2019-12-31 01:14:34
【问题描述】:

我有一个成功上传到 Heroku 的应用程序,一切正常。使用rails app:update 命令从版本 6.0.0rc1 更新到 6.0.0 后,我将应用程序部署到 heroku,然后在服务器启动时 Heroku 崩溃。

2019-08-20T12:45:56.047319+00:00 heroku[web.1]: State changed from crashed to starting
2019-08-20T12:46:01.995009+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}`
2019-08-20T12:46:04.051365+00:00 app[web.1]: Puma starting in single mode...
2019-08-20T12:46:04.051387+00:00 app[web.1]: * Version 3.12.1 (ruby 2.6.1-p33), codename: Llamas in Pajamas
2019-08-20T12:46:04.051389+00:00 app[web.1]: * Min threads: 5, max threads: 5
2019-08-20T12:46:04.051390+00:00 app[web.1]: * Environment: production
2019-08-20T12:46:08.886669+00:00 heroku[web.1]: State changed from starting to crashed
2019-08-20T12:46:08.769945+00:00 app[web.1]: * Listening on tcp://0.0.0.0:32178
2019-08-20T12:46:08.770225+00:00 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.6.0/bin/puma)
2019-08-20T12:46:08.770272+00:00 app[web.1]: Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/pids/server.pid
2019-08-20T12:46:08.770276+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `initialize'
2019-08-20T12:46:08.770277+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `open'
2019-08-20T12:46:08.770278+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:133:in `write_pid'
2019-08-20T12:46:08.770280+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:106:in `write_state'
2019-08-20T12:46:08.770281+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/single.rb:103:in `run'
2019-08-20T12:46:08.770282+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/launcher.rb:186:in `run'
2019-08-20T12:46:08.770284+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/cli.rb:80:in `run'
2019-08-20T12:46:08.770285+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/bin/puma:10:in `<top (required)>'
2019-08-20T12:46:08.770287+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/bin/puma:23:in `load'
2019-08-20T12:46:08.770289+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/bin/puma:23:in `<top (required)>'
2019-08-20T12:46:08.867275+00:00 heroku[web.1]: Process exited with status 1

由于某种原因,服务器启动时没有创建tmp/pids/server.pid

你能帮我解决这个问题吗? 我在谷歌没有找到解决方案

【问题讨论】:

    标签: ruby-on-rails ruby heroku


    【解决方案1】:

    您需要修改您的.gitignore 文件,以使用.keep 文件明确允许tmp/pids 目录通过。确保您的 .gitignore 看起来像这样:

    /tmp/*
    /tmp/pids/*
    !/tmp/.keep
    !/tmp/pids
    !/tmp/pids/.keep
    

    然后是touch tmp/pids/.keep

    【讨论】:

    • 没有工作... pids 文件夹未推送到 heroku 出现错误-> launcher.rb:244:in `write': No such file or directory @ rb_sysopen - tmp/pids/server .pid (Errno::ENOENT)
    • 当我升级到 5.2.6 时发生了这种情况,但是当 rails new 时,.gitignore 文件中有 Ignore pidfiles, but keep the directory. 部分。
    • 这在 Heroku 上对我有用。
    【解决方案2】:

    好的,我通过从 Rails 升级期间添加的 config/puma.rb 中删除行 pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 解决了这个问题 :)

    【讨论】:

    • 不知道为什么人们投反对票,但感谢您回来回答
    • 可能,您已经合并而不是在升级时检查文件更改!
    • 是的,但我只检查了升级前更改的那些文件。
    • 我从 Rails 4.2.11.1 升级到 Rails 5.2.5 时遇到了同样的问题。删除该行也为我解决了问题。
    【解决方案3】:

    您可以使用.keep 文件将tmp/pids 文件夹添加到版本控制。这会将文件夹置于版本控制中,因此当它被克隆到 Heroku 时,该文件夹就在那里。

    您可能还需要编辑 .gitignore 文件,使其不会忽略 tmp/pids 目录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-09
      相关资源
      最近更新 更多