【问题标题】:Ruby on rails app not deploying on HerokuRuby on rails 应用程序未部署在 Heroku 上
【发布时间】:2018-06-10 18:32:46
【问题描述】:

总的来说,我对开发非常陌生,并且正在关注 Michael Hartl 的 rails book。我的“玩具应用”在我的本地服务器上运行良好,但由于某种原因,当我尝试通过 Heroku 部署它时,我收到错误代码 H10,并且描述为“应用崩溃”。

我不知道如何解决这个问题,并且在论坛上咨询了许多类似的问题,但似乎没有一个答案对我有用。最初尝试部署时,我收到一条“推送被拒绝”消息,但在运行 bundle update 后,一切似乎都处理得很好,除了我无法通过 heroku 查看应用程序。

关于如何解决此问题的任何建议?

Here's the full build-log from the deployment:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.3.4
-----> Installing dependencies using bundler 1.15.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
       Fetching gem metadata from https://rubygems.org/.........
       Fetching version metadata from https://rubygems.org/..
       Fetching dependency metadata from https://rubygems.org/.
       Using rake 12.3.0
       Using concurrent-ruby 1.0.5
       Using minitest 5.10.3
       Using thread_safe 0.3.6
       Using builder 3.2.3
       Using erubi 1.7.0
       Using mini_portile2 2.3.0
       Using crass 1.0.3
       Using rack 2.0.3
       Using nio4r 2.2.0
       Using websocket-extensions 0.1.3
       Using mini_mime 1.0.0
       Using arel 8.0.0
       Using bundler 1.15.2
       Using coffee-script-source 1.12.2
       Using execjs 2.7.0
       Using method_source 0.9.0
       Using thor 0.20.0
       Using ffi 1.9.18
       Using multi_json 1.12.2
       Using pg 0.21.0
       Using puma 3.11.0
       Using rb-fsevent 0.10.2
       Using tilt 2.0.8
       Using turbolinks-source 5.0.3
       Using i18n 0.9.1
       Using tzinfo 1.2.4
       Using nokogiri 1.8.1
       Using websocket-driver 0.6.5
       Using mail 2.7.0
       Using coffee-script 2.4.1
       Using uglifier 4.1.2
       Using rb-inotify 0.9.10
       Using turbolinks 5.0.1
       Using activesupport 5.1.4
       Using loofah 2.1.1
       Using rack-test 0.8.2
       Using sprockets 3.7.1
       Using sass-listen 4.0.0
       Using rails-html-sanitizer 1.0.3
       Using sass 3.5.4
       Using rails-dom-testing 2.0.3
       Using globalid 0.4.1
       Using activemodel 5.1.4
       Using jbuilder 2.7.0
       Using actionview 5.1.4
       Using activejob 5.1.4
       Using activerecord 5.1.4
       Using actionpack 5.1.4
       Using actioncable 5.1.4
       Using actionmailer 5.1.4
       Using railties 5.1.4
       Using sprockets-rails 3.2.1
       Using coffee-rails 4.2.2
       Using jquery-rails 4.3.1
       Using rails 5.1.4
       Using sass-rails 5.0.7
       Bundle complete! 18 Gemfile dependencies, 57 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into ./vendor/bundle.
       Bundle completed (2.73s)
       Cleaning up the bundler cache.
       Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
       The latest bundler is 1.16.1, but you are currently running 1.15.2.
       To update, run `gem install bundler`
-----> Installing node-v6.11.1-linux-x64
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       Yarn executable was not detected in the system.
       Download Yarn at https://yarnpkg.com/en/docs/install
       Asset precompilation completed (1.54s)
       Cleaning assets
       Running: rake assets:clean
###### WARNING:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:
       ruby '2.3.4'
       # See https://devcenter.heroku.com/articles/ruby-versions for more information.
###### WARNING:
       No Procfile detected, using the default web server.
       We recommend explicitly declaring how to boot your server process via a Procfile.
       https://devcenter.heroku.com/articles/ruby-default-web-server
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> console, rake, web, worker
-----> Compressing...
       Done: 37.3M
-----> Launching...
       Released v11
       https://still-everglades-21863.herokuapp.com/ deployed to Heroku

【问题讨论】:

  • 您能否发布部署中的完整构建日志?
  • 您检查过 Heroku 的应用程序日志吗?您可以使用他们的命令行工具来检索日志:devcenter.heroku.com/articles/logging#log-retrieval.
  • 我已编辑问题以包含完整的构建日志。Heroku 的日志返回应用程序崩溃消息错误代码 H10
  • 推送后你做了heroku run rake db:migrate吗?您显示的此构建日志没有错误顺便说一句,只有警告
  • 当我执行 heroku run rake db:migrate 时,我收到以下错误“Gem::LoadError: sqlite3 不是捆绑包的一部分。将其添加到您的 Gemfile”,但 sqlite3 在我的 Gemfile 中?

标签: ruby-on-rails ruby github heroku deployment


【解决方案1】:

SQLite 将数据存储在文件中。 Heroku 不允许存储用户的文件,因此您不能将 SQLite 与 Heroku 一起使用。相反,您应该切换到另一个数据库,如 PostgreSQL 或 MySQL。 Here你可以找到详情。

【讨论】:

  • 我已经完成了所有这些步骤,现在当我运行“git push heroku”时它处理得很好,但是当我运行“heroku run rails db:migrate”时,会出现以下消息:“ PG::ConnectionBad: 无法连接到服务器:连接被拒绝服务器是否在主机“localhost”(127.0.0.1)上运行并接受端口 5432 上的 TCP/IP 连接?”
  • 似乎数据库还没有在heroku中创建。创建数据库后,一切正常。很抱歉成为这样的菜鸟。感谢您的帮助!
猜你喜欢
  • 2016-01-06
  • 2016-12-25
  • 1970-01-01
  • 2011-10-29
  • 2015-10-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-15
相关资源
最近更新 更多