为什么将 Rails 升级到 6.0.0 后 Heroku Rails App 会崩溃?

Dan*_*yan 6 ruby ruby-on-rails heroku

我有一个成功上传到 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
Run Code Online (Sandbox Code Playgroud)

出于某种原因,tmp/pids/server.pid服务器启动时不会创建 。

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

Dan*_*yan 13

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


bsw*_*ton 10

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

/tmp/*
/tmp/pids/*
!/tmp/.keep
!/tmp/pids
!/tmp/pids/.keep
Run Code Online (Sandbox Code Playgroud)

然后touch tmp/pids/.keep