这是我第一次尝试使用heroku进行部署。由于它已经在heroku上构建了应用,因此无法正常工作 It shows this error on the view and
当我尝试运行heroku日志--tail时。它显示以下错误。
2018-09-05T08:34:50.778080+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=project-x-staging.herokuapp.com request_id=805ce93c-2b60-426f-bcb8-575428a6affc fwd="118.173.233.9" dyno= connect= service= status=503 bytes= protocol=https
2018-09-05T08:34:51.610636+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=project-x-staging.herokuapp.com request_id=7de53f2d-7310-4ec2-9a07-cfefae8f7ddc fwd="118.173.233.9" dyno= connect= service= status=503 bytes= protocol=https
此处完整日志
2018-09-05T09:41:08.709165+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
2018-09-05T09:41:08.709213+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
2018-09-05T09:41:08.709261+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
2018-09-05T09:41:08.709362+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/callbacks.rb:36:in `call'
2018-09-05T09:41:08.709308+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:90:in `run_callbacks'
2018-09-05T09:41:08.709412+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
2018-09-05T09:41:08.709463+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
2018-09-05T09:41:08.709520+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
2018-09-05T09:41:08.709569+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:36:in `call_app'
2018-09-05T09:41:08.709616+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `block in call'
2018-09-05T09:41:08.709664+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `block in tagged'
2018-09-05T09:41:08.709758+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `tagged'
2018-09-05T09:41:08.709711+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:26:in `tagged'
2018-09-05T09:41:08.709817+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `call'
2018-09-05T09:41:08.709962+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/runtime.rb:22:in `call'
2018-09-05T09:41:08.710009+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
2018-09-05T09:41:08.710056+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/executor.rb:12:in `call'
2018-09-05T09:41:08.709865+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/request_id.rb:24:in `call'
2018-09-05T09:41:08.709913+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
2018-09-05T09:41:08.710103+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/static.rb:136:in `call'
2018-09-05T09:41:08.710151+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
2018-09-05T09:41:08.710198+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/railties-5.0.0/lib/rails/engine.rb:522:in `call'
2018-09-05T09:41:08.710251+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/handler/webrick.rb:86:in `service'
2018-09-05T09:41:08.710300+00:00 app[web.1]: vendor/ruby-2.4.4/lib/ruby/2.4.0/webrick/httpserver.rb:140:in `service'
2018-09-05T09:41:08.710347+00:00 app[web.1]: vendor/ruby-2.4.4/lib/ruby/2.4.0/webrick/httpserver.rb:96:in `run'
2018-09-05T09:41:08.710422+00:00 app[web.1]: vendor/ruby-2.4.4/lib/ruby/2.4.0/webrick/server.rb:308:in `block in start_thread'
2018-09-05T09:41:09.213725+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=project-x-staging.herokuapp.com request_id=cb647327-8c03-4fde-bac0-012a9868e6d1 fwd="118.173.233.9" dyno=web.1 connect=1ms service=5ms status=200 bytes=228 protocol=https
2018-09-05T09:44:45.700672+00:00 app[web.1]: Started GET "/" for 118.173.233.9 at 2018-09-05 09:44:45 +0000
2018-09-05T09:44:45.702908+00:00 app[web.1]: Processing by PagesController#index as HTML
2018-09-05T09:44:45.741007+00:00 app[web.1]: Completed 500 Internal Server Error in 38ms
2018-09-05T09:44:45.742704+00:00 app[web.1]:
2018-09-05T09:44:45.742751+00:00 app[web.1]: Gem::LoadError (Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).):
2018-09-05T09:44:45.742818+00:00 app[web.1]:
2018-09-05T09:44:45.742858+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.0/lib/active_record/connection_adapters/connection_specification.rb:176:in `rescue in spec'
2018-09-05T09:44:45.742894+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.0/lib/active_record/connection_adapters/connection_specification.rb:173:in `spec'
2018-09-05T09:44:45.742934+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.0/lib/active_record/connection_handling.rb:53:in `establish_connection'
2018-09-05T09:44:45.743003+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.0/lib/active_record/railtie.rb:125:in `block (2 levels) in <class:Railtie>'
2018-09-05T09:44:45.743051+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
2018-09-05T09:44:45.743102+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
2018-09-05T09:44:45.743163+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
2018-09-05T09:44:45.743195+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
2018-09-05T09:44:45.743236+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
2018-09-05T09:44:45.743267+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.0/lib/active_record/base.rb:324:in `<module:ActiveRecord>'
2018-09-05T09:44:45.743338+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.0/lib/active_record/base.rb:24:in `<top (required)>'
2018-09-05T09:44:45.743372+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
2018-09-05T09:44:45.743400+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `block in require'
2018-09-05T09:44:45.743585+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency'
2018-09-05T09:44:45.743587+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/dependencies.rb:293:in `require'
2018-09-05T09:44:45.743589+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.0/lib/active_record/railties/controller_runtime.rb:36:in `append_info_to_payload'
2018-09-05T09:44:45.743591+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_controller/metal/instrumentation.rb:36:in `ensure in block in process_action'
2018-09-05T09:44:45.743593+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_controller/metal/instrumentation.rb:36:in `block in process_action'
2018-09-05T09:44:45.743595+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/notifications.rb:164:in `block in instrument'
2018-09-05T09:44:45.743652+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
2018-09-05T09:44:45.743693+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/notifications.rb:164:in `instrument'
2018-09-05T09:44:45.743732+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
2018-09-05T09:44:45.743893+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
2018-09-05T09:44:45.743896+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.0/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
2018-09-05T09:44:45.743899+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/abstract_controller/base.rb:126:in `process'
2018-09-05T09:44:45.743901+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionview-5.0.0/lib/action_view/rendering.rb:30:in `process'
2018-09-05T09:44:45.743907+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_controller/metal.rb:190:in `dispatch'
2018-09-05T09:44:45.743940+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_controller/metal.rb:262:in `dispatch'
2018-09-05T09:44:45.744013+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
2018-09-05T09:44:45.744048+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/routing/route_set.rb:32:in `serve'
2018-09-05T09:44:45.744083+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/journey/router.rb:39:in `block in serve'
2018-09-05T09:44:45.744120+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/journey/router.rb:26:in `each'
2018-09-05T09:44:45.744198+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/journey/router.rb:26:in `serve'
2018-09-05T09:44:45.744227+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/routing/route_set.rb:725:in `call'
2018-09-05T09:44:45.744308+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/etag.rb:25:in `call'
2018-09-05T09:44:45.744363+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/conditional_get.rb:25:in `call'
2018-09-05T09:44:45.744396+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/head.rb:12:in `call'
2018-09-05T09:44:45.744440+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:232:in `context'
2018-09-05T09:44:45.744548+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/cookies.rb:613:in `call'
2018-09-05T09:44:45.744469+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:226:in `call'
2018-09-05T09:44:45.744578+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
2018-09-05T09:44:45.744615+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
2018-09-05T09:44:45.744679+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
2018-09-05T09:44:45.744722+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:90:in `run_callbacks'
2018-09-05T09:44:45.744759+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/callbacks.rb:36:in `call'
2018-09-05T09:44:45.744795+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
2018-09-05T09:44:45.744882+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
2018-09-05T09:44:45.744889+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
2018-09-05T09:44:45.744929+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:36:in `call_app'
2018-09-05T09:44:45.744965+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `block in call'
2018-09-05T09:44:45.745146+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `block in tagged'
2018-09-05T09:44:45.745148+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:26:in `tagged'
2018-09-05T09:44:45.745150+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/tagged_logging.rb:70:in `tagged'
2018-09-05T09:44:45.745152+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/railties-5.0.0/lib/rails/rack/logger.rb:24:in `call'
2018-09-05T09:44:45.745153+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/request_id.rb:24:in `call'
2018-09-05T09:44:45.745159+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
2018-09-05T09:44:45.745368+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/runtime.rb:22:in `call'
2018-09-05T09:44:45.745371+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.0/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
2018-09-05T09:44:45.745373+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/executor.rb:12:in `call'
2018-09-05T09:44:45.745374+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/static.rb:136:in `call'
2018-09-05T09:44:45.745376+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
2018-09-05T09:44:45.745382+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/railties-5.0.0/lib/rails/engine.rb:522:in `call'
2018-09-05T09:44:45.745414+00:00 app[web.1]: vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/handler/webrick.rb:86:in `service'
2018-09-05T09:44:45.745448+00:00 app[web.1]: vendor/ruby-2.4.4/lib/ruby/2.4.0/webrick/httpserver.rb:140:in `service'
2018-09-05T09:44:45.745486+00:00 app[web.1]: vendor/ruby-2.4.4/lib/ruby/2.4.0/webrick/httpserver.rb:96:in `run'
2018-09-05T09:44:45.745555+00:00 app[web.1]: vendor/ruby-2.4.4/lib/ruby/2.4.0/webrick/server.rb:308:in `block in start_thread'
2018-09-05T09:44:46.110843+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=project-x-staging.herokuapp.com request_id=551b54be-bd1e-4b57-b75e-7580c573024d fwd="118.173.233.9" dyno=web.1 connect=0ms service=2ms status=200 bytes=228 protocol=https
以下是我的Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '5.0'
gem 'font-awesome-rails'
# Use SCSS for stylesheets
gem 'bootstrap', '~> 4.1.3'
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
gem 'coffee-script-source', '~> 1.11', '>= 1.11.1'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
请帮助我找出解决此问题的方法。谢谢:)
答案 0 :(得分:0)
我编辑了帖子以正确格式化日志。
Heroku将postgres用于其数据库,AFAIK不可商议。
似乎您没有安装pg
宝石。
答案 1 :(得分:0)
您缺少了Postgres,这是Heroku使用/需要的。 要使其正常工作(肮脏的样式),请将Postgres添加到Gemfile中的生产模块中:
gem 'pg', group: :production
并将默认的sqlite 3 gem移入开发/测试块:
group :development, :test do
gem 'sqlite3'
end
然后重新推送到Heroku。
这意味着您将在Heroku上运行Postgres数据库,并在本地运行sqlite3数据库。
但是,理想情况下您要在所有环境中运行相同的数据库,在这种情况下,必须在本地安装和运行Postgres。
答案 2 :(得分:0)
谢谢您以上所有评论,并尝试为我解决。 我是Rails和Heroku的新手。我不知道自己在做什么,我仍在尝试了解其结构和其他内容。解决此问题。我添加的只是添加,
红宝石'2.3.1'
在我的Gemfile中。在我添加之后,它修复了。所有CSS都不在heroku上运行。