Heroku上的Rails 4应用程序为500ing,但日志中没有错误消息 [英] Rails 4 app on Heroku is 500ing, but no error message in logs

查看:101
本文介绍了Heroku上的Rails 4应用程序为500ing,但日志中没有错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个新的Rails 4 beta应用程序并将其部署到Heroku(使用Ruby 2.0.0,并通过Procfile使用Unicorn).

I've made a new Rails 4 beta app and deployed it to Heroku (using Ruby 2.0.0, and Unicorn via a Procfile).

它在foreman start上可以在本地正常运行,但是当我访问已部署应用程序的主页时,我只会看到标准的Heroku 500错误:

It runs fine locally with foreman start, but when I visit the homepage of the deployed app, I just get the standard Heroku 500 error:

We're sorry, but something went wrong.
If you are the application owner check the logs for more information.

但是,在日志中,没有错误.我不知道是什么导致了500.

However, in the logs, there are no errors. I've no idea what is causing the 500.

这是我上一个git push heroku master的输出:

Counting objects: 6, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 656 bytes, done.
Total 4 (delta 2), reused 0 (delta 0)

-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
       Using rake (10.0.4)
       Using i18n (0.6.4)
       Using minitest (4.7.3)
       Using multi_json (1.7.2)
       Using atomic (1.1.8)
       Using thread_safe (0.1.0)
       Using tzinfo (0.3.37)
       Using activesupport (4.0.0.beta1)
       Using builder (3.1.4)
       Using erubis (2.7.0)
       Using rack (1.5.2)
       Using rack-test (0.6.2)
       Using actionpack (4.0.0.beta1)
       Using mime-types (1.23)
       Using polyglot (0.3.3)
       Using treetop (1.4.12)
       Using mail (2.5.3)
       Using actionmailer (4.0.0.beta1)
       Using activemodel (4.0.0.beta1)
       Using activerecord-deprecated_finders (0.0.3)
       Using arel (4.0.0)
       Using activerecord (4.0.0.beta1)
       Using coffee-script-source (1.6.2)
       Using execjs (1.4.0)
       Using coffee-script (2.2.0)
       Using json (1.7.7)
       Using rdoc (3.12.2)
       Using thor (0.18.1)
       Using railties (4.0.0.beta1)
       Using coffee-rails (4.0.0)
       Using hike (1.2.2)
       Using jbuilder (1.0.2)
       Using jquery-rails (2.2.1)
       Using kgio (2.8.0)
       Using mysql2 (0.3.11)
       Using bundler (1.3.2)
       Using tilt (1.3.7)
       Using sprockets (2.9.3)
       Using sprockets-rails (2.0.0.rc4)
       Using rails (4.0.0.beta1)
       Using raindrops (0.11.0)
       Using sass (3.2.8)
       Using sass-rails (4.0.0.rc1)
       Using turbolinks (1.1.1)
       Using uglifier (2.0.1)
       Using unicorn (4.6.2)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       I, [2013-04-23T22:28:44.559735 #871]  INFO -- : Writing /tmp/build_33m76p0rij8a5/public/assets/rails-d8fb6a2617998f32edf5edb354fc5326.png
       I, [2013-04-23T22:28:49.911890 #871]  INFO -- : Writing /tmp/build_33m76p0rij8a5/public/assets/application-d4a508061cd56ce9e544945495285e0c.js
       I, [2013-04-23T22:28:50.120141 #871]  INFO -- : Writing /tmp/build_33m76p0rij8a5/public/assets/application-a3b89b66a8471f3e75abb239e3b35c7d.css
       Asset precompilation completed (8.30s)
-----> Rails plugin injection
-----> Discovering process types
       Procfile declares types      -> web
       Default types for Ruby/Rails -> console, rake, worker

-----> Compiled slug size: 35.0MB
-----> Launching... done, v21
       http://blofs.herokuapp.com deployed to Heroku

To git@heroku.com:blofs.git
   32e51a2..37d989c  master -> master

这是该推送的日志:

2013-04-23T22:28:06.650049+00:00 heroku[slugc]: Slug compilation started
2013-04-23T22:29:11.194613+00:00 heroku[api]: Release v21 created by callum.locke@gmail.com
2013-04-23T22:29:11.365908+00:00 heroku[api]: Deploy 37d989c by callum.locke@gmail.com
2013-04-23T22:29:11.441066+00:00 heroku[web.1]: State changed from up to starting
2013-04-23T22:29:11.932952+00:00 heroku[slugc]: Slug compilation finished
2013-04-23T22:29:12.858139+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-04-23T22:29:13.194707+00:00 app[web.1]: I, [2013-04-23T22:29:13.194495 #2]  INFO -- : reaped #<Process::Status: pid 5 exit 0> worker=0
2013-04-23T22:29:13.194902+00:00 app[web.1]: I, [2013-04-23T22:29:13.194747 #2]  INFO -- : master complete
2013-04-23T22:29:14.312014+00:00 heroku[web.1]: Process exited with status 0
2013-04-23T22:29:14.338943+00:00 heroku[web.1]: Starting process with command `bundle exec unicorn -p 25281 -E $RACK_ENV`
2013-04-23T22:29:15.717687+00:00 app[web.1]: I, [2013-04-23T22:29:15.717387 #2]  INFO -- : listening on addr=0.0.0.0:25281 fd=7
2013-04-23T22:29:15.717916+00:00 app[web.1]: I, [2013-04-23T22:29:15.717861 #2]  INFO -- : worker=0 spawning...
2013-04-23T22:29:15.721526+00:00 app[web.1]: I, [2013-04-23T22:29:15.721385 #2]  INFO -- : master process ready
2013-04-23T22:29:15.723623+00:00 app[web.1]: I, [2013-04-23T22:29:15.723389 #5]  INFO -- : worker=0 spawned pid=5
2013-04-23T22:29:15.723805+00:00 app[web.1]: I, [2013-04-23T22:29:15.723750 #5]  INFO -- : Refreshing Gem list
2013-04-23T22:29:16.305653+00:00 heroku[web.1]: State changed from starting to up
2013-04-23T22:29:16.891063+00:00 app[web.1]: I, [2013-04-23T22:29:16.890882 #5]  INFO -- : worker=0 ready

在那之后,我试图在浏览器中加载主页,而这是出现在日志中的仅有的两行:

After that, I tried to load the homepage in my browser, and these are the only two extra lines that appeared in the logs:

2013-04-23T22:29:26.685651+00:00 heroku[router]: at=info method=GET path=/ host=blofs.herokuapp.com fwd="46.65.16.44" dyno=web.1 connect=2ms service=156ms status=500 bytes=706
2013-04-23T22:29:26.973073+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=blofs.herokuapp.com fwd="46.65.16.44" dyno=web.1 connect=1ms service=5ms status=200 bytes=0

有人知道这个问题可能是什么吗?

Does anyone have any idea what the problem could be?

其他可能相关的内容:

  • 我已禁用了标准的Heroku Postgres插件,而是使用ClearDB MySQL插件.
  • 我尝试手动将DATABASE_URL环境变量从以前的值(即使删除了postgres插件后,仍然是postgres URL)更改为与CLEARDB_DATABASE_URL var(mysql一个)相同的值.这似乎没有什么区别.
  • 我已将ruby '2.0.0'添加到我的Gemfile中,并添加了mysql2unicorn宝石.而且我使用了 https://devcenter.heroku.com/articles/上建议的config/unicorn.rb rails-unicorn
  • 我的Procfile仅包含:web: bundle exec unicorn -p $PORT -E $RACK_ENV
  • foreman start上可以在本地正常工作.
  • 除了上述修改之外,它基本上是使用rails new创建的即用型应用程序.
  • I've disabled the standard Heroku Postgres addon and am using the ClearDB MySQL addon instead.
  • I've tried manually changing the DATABASE_URL environment variable from the previous value (which was still the postgres URL even after I removed the postgres addon) to the same value as the CLEARDB_DATABASE_URL var (the mysql one). This didn't seem to make any difference.
  • I have added ruby '2.0.0' to my Gemfile, and added mysql2 and unicorn gems. And I've used the config/unicorn.rb suggested at https://devcenter.heroku.com/articles/rails-unicorn
  • My Procfile only contains: web: bundle exec unicorn -p $PORT -E $RACK_ENV
  • It works fine locally with foreman start.
  • Other than the modifications described above, it's basically an out-of-the-box app created with rails new.

推荐答案

您需要将gem 'rails_12factor'添加到您的Gemfile中.这是Heroku的临时修复程序,目的是使Rails 4+可以与其服务一起使用.

You need to add gem 'rails_12factor' to your Gemfile. It's a temporary fix from Heroku to make Rails 4+ work with their service.

请参见在Heroku上使用Rails 4.x入门在Heroku上使用Rails 5.x入门.

这篇关于Heroku上的Rails 4应用程序为500ing,但日志中没有错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆