2014-02-23 59 views
1

我推送我的應用程序到Heroku,並得到「我們很抱歉,但出了問題(500)」 這是爲什麼?我知道錯誤信息是來自我自己的/ public目錄中的一個文件,標題爲500.html,但我不知道爲什麼會發生這種情況。爲什麼我的應用程序推向Heroku時出現錯誤500「我們很抱歉,但出現了問題」?

我的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: 
+0

該錯誤意味着什麼是你的代碼錯誤。這真的可以是任何事情。但最有可能是一個不合適的字符,語法錯誤。 – sonnyhe2002

回答

1

錯誤

500 server error基本上是所有的時間你的服務器有一個內部問題的蓋子(可以不提供您的要求)

Rails的錯誤處理的路線所有的錯誤,你/public目錄中一系列文件名爲422.html404.html500.html - 代表了最常見的錯誤

你所看到的500錯誤可能是應用內的任何原因。這裏是我會做什麼來解決它:


環境

你得到的生產誤差,這意味着與環境的差異將導致該問題

我會首先看看有什麼變化。通常情況下,它的數據庫,或者一些環境設置(不同DB提供程序等)是造成問題的


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" <[email protected]>}, 
    :exception_recipients => %w{[email protected]} 
    } 

你需要得到的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 
    } 
相關問題