【问题标题】:Why am I getting this Heroku and Rails error?为什么我会收到这个 Heroku 和 Rails 错误?
【发布时间】:2014-07-28 08:47:25
【问题描述】:

我正在尝试在 Heroku 上部署我的 Rails Web 应用程序。 我使用脚手架生成两个表。在我的机器上,使用 SQLite 一切正常。

我将我的应用上传到 heroku,但现在遇到了一个奇怪的问题。当我使用:

heroku config:add RACK_ENV=development

它适用于 SQL 表。当我将它改回生产时,它显示:

We're sorry, but something went wrong.

We've been notified about this issue and we'll take a look at it shortly.

我在终端输入:

heroku logs

输出:

2011-09-07T13:44:31+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-07T13:44:31+00:00 app[web.1]: >> Listening on 0.0.0.0:16691, CTRL+C to stop
2011-09-07T13:44:31+00:00 heroku[web.1]: State changed from starting to up
2011-09-07T13:44:32+00:00 app[web.1]: cache: [GET /users] miss
2011-09-07T13:44:32+00:00 heroku[router]: GET falling-winter-505.heroku.com/users dyno=web.1 queue=0 wait=0ms service=193ms status=500 bytes=728
2011-09-07T13:44:47+00:00 app[web.1]: >> Stopping ...
2011-09-07T13:56:25+00:00 app[web.1]: cache: [GET /users] miss
2011-09-07T13:56:25+00:00 heroku[router]: GET falling-winter-505.heroku.com/users dyno=web.1 queue=0 wait=0ms service=26ms status=500 bytes=728
2011-09-07T13:56:25+00:00 heroku[nginx]: 95.26.72.50 - - [07/Sep/2011:06:56:25 -0700] "GET /users HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" falling-winter-505.heroku.com
2011-09-07T15:00:53+00:00 heroku[web.1]: Idling
2011-09-07T15:00:54+00:00 heroku[web.1]: State changed from up to down
2011-09-07T15:00:54+00:00 heroku[web.1]: State changed from down to created
2011-09-07T15:00:54+00:00 heroku[web.1]: State changed from created to starting
2011-09-07T15:00:55+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-07T15:00:55+00:00 app[web.1]: >> Stopping ...
2011-09-07T15:00:55+00:00 heroku[web.1]: Process exited
2011-09-07T15:00:59+00:00 heroku[web.1]: Starting process with command `thin -p 8370 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-07T15:01:03+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-07T15:01:03+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-07T15:01:03+00:00 app[web.1]: >> Listening on 0.0.0.0:8370, CTRL+C to stop
2011-09-07T15:01:04+00:00 heroku[web.1]: State changed from starting to up
2011-09-07T16:07:12+00:00 heroku[web.1]: State changed from up to down
2011-09-07T16:07:13+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-07T16:07:13+00:00 app[web.1]: >> Stopping ...
2011-09-07T16:07:14+00:00 heroku[web.1]: Process exited 
2011-09-07T17:10:28+00:00 heroku[web.1]: Unidling
2011-09-07T17:10:28+00:00 heroku[web.1]: State changed from down to created
2011-09-07T17:10:28+00:00 heroku[web.1]: State changed from created to starting
2011-09-07T17:10:40+00:00 heroku[web.1]: Starting process with command `thin -p 35396 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-07T17:10:44+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-07T17:10:44+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-07T17:10:44+00:00 app[web.1]: >> Listening on 0.0.0.0:35396, CTRL+C to stop
2011-09-07T17:10:45+00:00 heroku[web.1]: State changed from starting to up
2011-09-07T17:10:46+00:00 app[web.1]: cache: [GET /users] miss
2011-09-07T17:10:46+00:00 heroku[router]: GET falling-winter-505.heroku.com/users dyno=web.1 queue=0 wait=7ms service=173ms status=500 bytes=728
2011-09-07T17:10:46+00:00 app[web.1]: cache: [GET /favicon.ico] miss, store
2011-09-07T17:10:46+00:00 heroku[router]: GET falling-winter-505.heroku.com/favicon.ico dyno=web.1 queue=0 wait=0ms service=9ms status=200 bytes=0
2011-09-07T17:54:01+00:00 app[web.1]: cache: [GET /] miss
2011-09-07T17:54:01+00:00 heroku[router]: GET falling-winter-505.heroku.com/ dyno=web.1 queue=0 wait=0ms service=3ms status=200 bytes=5907
2011-09-07T17:54:01+00:00 heroku[nginx]: 95.26.190.212 - - [07/Sep/2011:10:54:01 -0700] "GET / HTTP/1.1" 200 1865 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" falling-winter-505.heroku.com
2011-09-07T17:54:02+00:00 app[web.1]: cache: [GET /assets/rails.png] miss, store
2011-09-07T17:54:02+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/rails.png dyno=web.1 queue=0 wait=0ms service=12ms status=200 bytes=6646
2011-09-07T17:54:02+00:00 heroku[nginx]: 95.26.190.212 - - [07/Sep/2011:10:54:02 -0700] "GET /assets/rails.png HTTP/1.1" 200 6646 "http://falling-winter-505.heroku.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" falling-winter-505.heroku.com
2011-09-07T17:54:09+00:00 app[web.1]: cache: [GET /users] miss
2011-09-07T17:54:09+00:00 heroku[router]: GET falling-winter-505.heroku.com/users dyno=web.1 queue=0 wait=0ms service=14ms status=500 bytes=728
2011-09-07T17:54:09+00:00 heroku[nginx]: 95.26.190.212 - - [07/Sep/2011:10:54:09 -0700] "GET /users HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" falling-winter-505.heroku.com
2011-09-07T18:01:13+00:00 app[web.1]: cache: [GET /users] miss
2011-09-07T18:01:13+00:00 heroku[router]: GET falling-winter-505.heroku.com/users dyno=web.1 queue=0 wait=0ms service=30ms status=500 bytes=728
2011-09-07T18:01:13+00:00 heroku[nginx]: 95.26.190.212 - - [07/Sep/2011:11:01:13 -0700] "GET /users HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" falling-winter-505.heroku.com
2011-09-07T18:03:29+00:00 app[web.1]: cache: [GET /users] miss
2011-09-07T18:03:29+00:00 heroku[router]: GET falling-winter-505.heroku.com/users dyno=web.1 queue=0 wait=0ms service=12ms status=500 bytes=728
2011-09-07T18:03:29+00:00 heroku[nginx]: 95.26.190.212 - - [07/Sep/2011:11:03:29 -0700] "GET /users HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" falling-winter-505.heroku.com
2011-09-07T18:03:42+00:00 heroku[api]: Config add RACK_ENV by g...@gmail.com
2011-09-07T18:03:42+00:00 heroku[api]: Release v9 created by g...@gmail.com
2011-09-07T18:03:42+00:00 heroku[web.1]: State changed from up to bouncing
2011-09-07T18:03:42+00:00 heroku[web.1]: State changed from bouncing to created
2011-09-07T18:03:42+00:00 heroku[web.1]: State changed from created to starting
2011-09-07T18:03:44+00:00 heroku[web.1]: Stopping process with S

2011-09-07T18:03:44+00:00 app[web.1]: >> Stopping ...
2011-09-07T18:03:44+00:00 heroku[web.1]: Process exited
2011-09-07T18:03:46+00:00 heroku[web.1]: Starting process with command `thin -p 16194 -e development -R /home/heroku_rack/heroku.ru start`
2011-09-07T18:03:49+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-07T18:03:49+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-07T18:03:49+00:00 app[web.1]: >> Listening on 0.0.0.0:16194, CTRL+C to stop
2011-09-07T18:03:49+00:00 heroku[web.1]: State changed from starting to up
2011-09-07T18:03:52+00:00 heroku[router]: GET falling-winter-505.heroku.com/users dyno=web.1 queue=0 wait=0ms service=2057ms status=200 bytes=1677
2011-09-07T18:03:52+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/application.css dyno=web.1 queue=0 wait=0ms service=4ms status=200 bytes=314
2011-09-07T18:03:52+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/microposts.css dyno=web.1 queue=0 wait=0ms service=6ms status=200 bytes=0
2011-09-07T18:03:52+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/jquery_ujs.js dyno=web.1 queue=0 wait=0ms service=10ms status=200 bytes=13425
2011-09-07T18:03:53+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/jquery.js dyno=web.1 queue=0 wait=0ms service=26ms status=200 bytes=236203
2011-09-07T18:03:53+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/users.css dyno=web.1 queue=1 wait=30ms service=7ms status=200 bytes=0
2011-09-07T18:03:53+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/scaffolds.css dyno=web.1 queue=2 wait=40ms service=7ms status=200 bytes=1755
2011-09-07T18:03:53+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/application.js dyno=web.1 queue=0 wait=0ms service=8ms status=200 bytes=404
2011-09-07T18:03:53+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/users.js dyno=web.1 queue=0 wait=4ms service=7ms status=200 bytes=30
2011-09-07T18:04:08+00:00 heroku[router]: GET falling-winter-505.heroku.com/microposts dyno=web.1 queue=0 wait=0ms service=67ms status=200 bytes=1977
2011-09-07T18:04:08+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/application.css dyno=web.1 queue=0 wait=0ms service=3ms status=200 bytes=314
2011-09-07T18:04:08+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/scaffolds.css dyno=web.1 queue=0 wait=0ms service=2ms status=200 bytes=1755
2011-09-07T18:04:08+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/users.css dyno=web.1 queue=0 wait=0ms service=3ms status=200 bytes=0
2011-09-07T18:04:08+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/microposts.css dyno=web.1 queue=1 wait=1ms service=2ms status=200 bytes=0
2011-09-07T18:04:08+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/microposts.js dyno=web.1 queue=0 wait=0ms service=4ms status=200 bytes=30
2011-09-07T18:04:08+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/jquery.js dyno=web.1 queue=0 wait=0ms service=12ms status=200 bytes=236203
2011-09-07T18:04:08+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/jquery_ujs.js dyno=web.1 queue=0 wait=0ms service=8ms status=200 bytes=13425
2011-09-07T18:04:09+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/users.js dyno=web.1 queue=0 wait=0ms service=5ms status=200 bytes=30
2011-09-07T18:04:09+00:00 heroku[router]: GET falling-winter-505.heroku.com/assets/application.js dyno=web.1 queue=1 wait=4ms service=3ms status=200 bytes=404
2011-09-07T18:04:21+00:00 heroku[api]: Config add RACK_ENV by g...@gmail.com
2011-09-07T18:04:21+00:00 heroku[api]: Release v10 created by g...@gmail.com
2011-09-07T18:04:21+00:00 heroku[web.1]: State changed from up to bouncing
2011-09-07T18:04:21+00:00 heroku[web.1]: State changed from bouncing to created
2011-09-07T18:04:21+00:00 heroku[web.1]: State changed from created to starting
2011-09-07T18:04:23+00:00 heroku[web.1]: Stopping process with SIGTERM
2011-09-07T18:04:23+00:00 app[web.1]: >> Stopping ...
2011-09-07T18:04:23+00:00 heroku[web.1]: Process exited
2011-09-07T18:04:24+00:00 heroku[web.1]: Starting process with command `thin -p 30135 -e production -R /home/heroku_rack/heroku.ru start`
2011-09-07T18:04:28+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious)
2011-09-07T18:04:28+00:00 app[web.1]: >> Maximum connections set to 1024
2011-09-07T18:04:28+00:00 app[web.1]: >> Listening on 0.0.0.0:30135, CTRL+C to stop
2011-09-07T18:04:29+00:00 heroku[web.1]: State changed from starting to up
2011-09-07T18:04:30+00:00 app[web.1]: cache: [GET /microposts] miss
2011-09-07T18:04:30+00:00 heroku[router]: GET falling-winter-505.heroku.com/microposts dyno=web.1 queue=0 wait=0ms service=164ms status=500 bytes=728
2011-09-07T18:04:30+00:00 heroku[nginx]: 95.26.190.212 - - [07/Sep/2011:11:04:30 -0700] "GET /microposts HTTP/1.1" 500 728 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:6.0.2) Gecko/20100101 Firefox/6.0.2" falling-winter-505.heroku.com

我的Ruby版本是1.9.2p290,Rails版本是3.1.0。

【问题讨论】:

  • 也许您忘记迁移 prod env 上的数据库?
  • 我在终端heroku rake db:migrate 中打印,然后在heroku db:push 中打印。在生产数据库中不起作用,只有在开发模式下才起作用。
  • 所以你的 production.rb 文件可能有问题

标签: ruby-on-rails ruby heroku


【解决方案1】:

考虑到它在开发模式下工作而不是在生产模式下工作,我想说最有可能的罪魁祸首是你的 production.rb 文件,正如 John Beynon 所建议的那样。我要尝试的下一件事是在本地以生产模式运行它。如果不出意外,您应该会得到更好的错误消息。

【讨论】:

    【解决方案2】:

    您似乎没有预编译您的资产。这是如何做到的http://guides.rubyonrails.org/asset_pipeline.html#in-production

    【讨论】:

      【解决方案3】:

      我知道我之前遇到过很多麻烦。这是 Heroku 根本不支持 sqlite3 的问题。他们用一个使用 mysql 的新文件删除了你的 database.yml 文件。需要检查的几件事:

      • 添加 mysql 或 mysql2 gem。
      • 您的应用程序是否依赖于数据库中的数据?如果是这样,您需要找到一种将新数据导入 mysql 的方法,因为您的 sqlite 数据库将无法工作。我最终使用 yaml_db gem 来执行此操作 (https://github.com/adamwiggins/yaml_db)。并且不得不用
      • 做一些事情

      【讨论】:

      • Heroku 使用 Postgres(因此使用 'pg' gem)而不是 Mysql。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多