当我将我的应用程序推送到Heroku时,为什么我收到错误500“我们很抱歉,但出了点问题”?

时间:2014-02-23 02:20:09

标签: ruby-on-rails mongodb heroku mongoid

我将我的应用推向了Heroku并且得到了“我们很抱歉,但出了点问题(500)” 为什么是这样?我知道错误消息来自我在/ public目录中的一个标题为500.html的文件,但我不确定为什么会发生这种情况。

我的heroku日志和我的mongoid.yml文件一样。感谢。

Heroku日志:

2014-02-23T02:12:14.311710+00:00 heroku[router]: at=info method=GET path=/ host=danacamilleapp.herokuapp.com request_id=25556ae0-c4ac-40f7-8008-bd8860b87039 fwd="72.89.235.136" dyno=web.1 connect=27ms service=18ms status=500 bytes=932
    2014-02-23T02:12:14.311277+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/sessions.rb:171:in `collection'
    2014-02-23T02:12:14.311277+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/sessions.rb:137:in `with_name'
    2014-02-23T02:12:14.311520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/contextual.rb:34:in `context'
    2014-02-23T02:12:14.311277+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/sessions/factory.rb:28:in `create'
    2014-02-23T02:12:14.311277+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/sessions/factory.rb:122:in `inject_ports'
    2014-02-23T02:12:14.311520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/contextual/mongo.rb:260:in `initialize'
    2014-02-23T02:12:14.311520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
    2014-02-23T02:12:14.311520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/contextual.rb:19:in `first'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_controller/metal/rescue.rb:29:in `process_action'
    2014-02-23T02:12:14.311520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/finders.rb:117:in `first'
    2014-02-23T02:12:14.311520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/locomotive_cms-2.4.1/lib/locomotive/routing/site_dispatcher.rb:23:in `fetch_site'
    2014-02-23T02:12:14.311520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:429:in `_run__204668899024992162__process_action__4317869837325352294__callbacks'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/abstract_controller/callbacks.rb:17:in `process_action'
    2014-02-23T02:12:14.311520+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/contextual.rb:21:in `rescue in first'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/notifications.rb:123:in `block in instrument'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/abstract_controller/rendering.rb:45:in `process'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    2014-02-23T02:12:14.311698+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/notifications.rb:123:in `instrument'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_controller/metal.rb:203:in `dispatch'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_controller/metal.rb:246:in `block in action'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/abstract_controller/base.rb:121:in `process'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:73:in `call'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:608:in `call'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
    2014-02-23T02:12:14.312217+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:36:in `call'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/rack/mongoid/middleware/identity_map.rb:34:in `block in call'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/locomotive_cms-2.4.1/lib/locomotive/middlewares/seo_trailing_slash.rb:16:in `call'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/cookies.rb:341:in `call'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/mongoid-3.1.6/lib/rack/mongoid/middleware/identity_map.rb:34:in `call'
    2014-02-23T02:12:14.312393+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/locomotive_cms-2.4.1/lib/locomotive/middlewares/inline_editor.rb:10:in `call'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/flash.rb:242:in `call'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/dragonfly-0.9.15/lib/dragonfly/cookie_monster.rb:9:in `call'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/head.rb:14:in `call'
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/rack/logger.rb:16:in `block in call'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
    2014-02-23T02:12:14.312746+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/tagged_logging.rb:22:in `tagged'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `_run__3023919651669179927__call__2916391713023742690__callbacks'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/rack/logger.rb:16:in `call'
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/request_id.rb:22:in `call'
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.16/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/rack/logger.rb:32:in `call_app'
    2014-02-23T02:12:14.312923+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/dragonfly-0.9.15/lib/dragonfly/middleware.rb:13:in `call'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/engine.rb:484:in `call'
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/connection.rb:55:in `process'
    2014-02-23T02:12:14.314052+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/runner.rb:200:in `run_command'
    2014-02-23T02:12:14.314052+00:00 app[web.1]: 
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.16/lib/action_dispatch/middleware/static.rb:63:in `call'
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/locomotive_cms-2.4.1/lib/locomotive/middlewares/permalink.rb:17:in `call'
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/connection.rb:80:in `pre_process'
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/connection.rb:82:in `block in pre_process'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/locomotive_cms-2.4.1/lib/locomotive/middlewares/cache.rb:20:in `call'
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/server.rb:162:in `start'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/connection.rb:41:in `receive_data'
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
    2014-02-23T02:12:14.313298+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/application.rb:231:in `call'
    2014-02-23T02:12:14.313480+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/railties-3.2.16/lib/rails/railtie/configurable.rb:30:in `method_missing'
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/backends/base.rb:73:in `start'
    2014-02-23T02:12:14.314052+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/runner.rb:156:in `run!'
    2014-02-23T02:12:14.314052+00:00 app[web.1]: 
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/controllers/controller.rb:87:in `start'
    2014-02-23T02:12:14.313860+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/lib/thin/connection.rb:80:in `catch'
    2014-02-23T02:12:14.314052+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/bin/thin:23:in `<main>'
    2014-02-23T02:12:14.314052+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/bin/thin:23:in `load'
    2014-02-23T02:12:14.314052+00:00 app[web.1]:   vendor/bundle/ruby/1.9.1/gems/thin-1.6.1/bin/thin:6:in `<top (required)>'
    2014-02-23T02:12:13.056223+00:00 heroku[router]: at=info method=GET path=/ host=danacamilleapp.herokuapp.com request_id=2d206784-0fff-4f81-b58c-96e73fd13722 fwd="72.89.235.136" dyno=web.1 connect=10ms service=15ms status=500 bytes=932

mongoid.yml

development:
  sessions:
    default:
      database: locomotive_dev
      hosts:
        - localhost:27017
  options:
    identity_map_enabled: true

test:
  sessions:
    default:
      database: locomotive_test
      hosts:
        - localhost:27017
  options:
    identity_map_enabled: true

production:
  uri: <%= ENV['MONGOHQ_URL'] %>
  sessions:
    default:
      database: locomotive_production
      hosts:

1 个答案:

答案 0 :(得分:1)

错误

500 server error基本上是服务器内部问题(并且无法呈现您的请求)的封面

Rails'错误处理将您的所有错误路由到/public目录中名为422.html404.html500.html的一系列文件 - 代表最常见的错误< / p>

您看到500错误的原因可能是您应用内的任何内容。以下是我要解决的问题:


<强>环境

您在生产中遇到错误,这意味着与环境的差异将导致问题

我首先要看看有什么变化。通常,它是导致问题的数据库或某些环境设置(不同的数据库提供程序等)


<强> DB

最常见的500错误是由开发和发现之间的DB不一致引起的。生产环境。我不知道mongoid,但是对于MYSQL / PGSQL这个问题,问题将与不在生产中迁移有关:

heroku run rake db:migrate通常会修复生产中的大多数数据库问题


例外通知

有一个名为exception notification的非常好的宝石(从Rails核心中提取),一块通过电子邮件发送错误通知的middlware:

  #config/environments/production.rb
  config.middleware.use ExceptionNotification::Rack,
  :email => {
    :email_prefix => "Subject",
    :sender_address => %{"notifier" <error@email.com>},
    :exception_recipients => %w{your_email@email.com}
  }

您需要在Heroku中获取SendGrid add-on并将其添加到production.rb

  #config/environments/production.rb
  config.action_mailer.smtp_settings = {
    :address        => 'smtp.sendgrid.net',
    :port           => '587',
    :authentication => :plain,
    :user_name      => ENV['SENDGRID_USERNAME'],
    :password       => ENV['SENDGRID_PASSWORD'],
    :domain         => 'heroku.com',
    :enable_starttls_auto => true
  }