问题
I pushed my app to Heroku and am getting "We're sorry, but something went wrong (500)" Why is this? I know the error message is coming from one of my own files in the /public directory titled 500.html but i'm not sure why this is happening.
My heroku logs are below as well as my mongoid.yml file. Thanks.
Heroku logs:
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:
Error
The 500 server error is basically a cover for all the times your server has an internal issue (and can't render your request)
Rails' error handling routes all your errors to a series of files inside your /public
directory called 422.html
, 404.html
and 500.html
-- representing the most common errors
The reason you're seeing the 500 error could be anything inside your app. Here's what I'd do to fix it:
Environment
You're getting the error in production, meaning a difference with the environments will be causing the issue
I would begin by looking at what's changing. Typically, it's the DB, or some environment settings (different DB provider etc) that's causing the issue
DB
Most common 500 errors are caused by DB inconsistencies between development & production environments. I don't know about mongoid, but with the likes of MYSQL / PGSQL the issue will be to do with not migrating in production:
heroku run rake db:migrate
normally fixes most db issues in production
Exception Notification
There's a very good gem called exception notification (extracted from the Rails core), a piece of middlware which sends error notifications by email:
#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}
}
You'll need to get the SendGrid add-on in Heroku and add this to your 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
}
来源:https://stackoverflow.com/questions/21963344/why-am-i-getting-error-500-were-sorry-but-something-went-wrong-when-pushing-m