部署 Ruby on Rails 教程-第一章最后一节关于 Heroku 的部署无法完成

accelee · 2019年03月27日 · 最后由 Rei 回复于 2019年03月31日 · 400 次阅读

部署到Heroku每一步都是按照书上来做的,完成heroku create后 $ git push -u heroku master

之后有个警告,不知道这个有没有问题? remote: ###### WARNING: remote: remote: Detecting rails configuration failed remote: set HEROKU_DEBUG_RAILS_RUNNER=1 to debug

用以下命令查看了一下记录 $heroku logs --tail

记录的最后一部分有如下的错误 2019-03-27T03:12:59.633659+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=evening-headland-50906.herokuapp.com request_id=ace14164-e2ea-4844-aefe-b50cdd276348 fwd="161.202.48.247" dyno= connect= service= status=503 bytes= protocol=https 2019-03-27T03:13:00.735273+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=evening-headland-50906.herokuapp.com request_id=164daabd-523f-4093-a979-105d95010a1e fwd="161.202.48.247" dyno= connect= service= status=503 bytes= protocol=https 2019-03-27T03:14:08.649975+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=evening-headland-50906.herokuapp.com request_id=b564bcd5-fd21-46be-b8cc-ef4f4da1ecf3 fwd="161.202.48.247" dyno= connect= service= status=503 bytes= protocol=https 2019-03-27T03:14:09.935469+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=evening-headland-50906.herokuapp.com request_id=0ac2ec6a-b39a-4737-b4ae-0c9fda5e4261 fwd="161.202.48.247" dyno= connect= service= status=503 bytes= protocol=https

程序在本地都是正常的,按照书上的步骤部署到Heroku就不行了,不知道应该从哪里查起?

共收到 10 条回复
1楼 已删除

heroku create 就已经自动设置 heroku 相关的 git config 了。

"App crashed" 要看 App 的日志,上面都是 heorku 路由的日志,把 logs 持续输出,再部署一遍看有没有应用输出。

为啥我没遇到过。。。

你heroku create是不是没有报任何错误? 你再重新做一遍 最后试试git push heroku master 不要加-u试试

我觉得 warning 不是问题。 问题是git push heroku master 的时候应该会有错误日志的吧?你贴的是请求日志,不利于排查这个问题,你的应用应该启动过程中就报错了。

lanzhiheng 回复

git push heroku master后的记录只有几个warning,没有错误 remote: Verifying deploy... done.

yfscret 回复

没有错误。没用

pynix 回复

好运啊

Rei 回复

以下是Heroku上的,表明部署是成功的,但是App打开后就显示Application error,真的是莫名其妙? Activity Feed accelee@gmail.com accelee@gmail.com: Deployed 6aeb03fb Today at 10:18 PM · v9 accelee@gmail.com accelee@gmail.com: Build succeeded Today at 10:17 PM · View build log

以下是所有的Heroku 上的所有日志:

----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.5.3
-----> 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.17.2). 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.2
       Using concurrent-ruby 1.1.5
       Using minitest 5.11.3
       Using thread_safe 0.3.6
       Using builder 3.2.3
       Using erubi 1.8.0
       Using mini_portile2 2.4.0
       Using crass 1.0.4
       Using rack 2.0.6
       Using nio4r 2.3.1
       Using websocket-extensions 0.1.3
       Using mini_mime 1.0.1
       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.2
       Using thor 0.20.3
       Using ffi 1.10.0
       Using multi_json 1.13.1
       Fetching pg 0.20.0
       Using puma 3.9.1
       Using rb-fsevent 0.10.3
       Using tilt 2.0.9
       Using turbolinks-source 5.2.0
       Using i18n 1.6.0
       Using tzinfo 1.2.5
       Using nokogiri 1.10.1
       Using rack-test 1.1.0
       Using sprockets 3.7.2
       Using mail 2.7.1
       Using websocket-driver 0.6.5
       Using coffee-script 2.4.1
       Using uglifier 3.2.0
       Using rb-inotify 0.10.0
       Using turbolinks 5.0.1
       Using activesupport 5.1.6
       Using loofah 2.2.3
       Using rails-dom-testing 2.0.3
       Using globalid 0.4.2
       Using activemodel 5.1.6
       Using jbuilder 2.7.0
       Using rails-html-sanitizer 1.0.4
       Using sass-listen 4.0.0
       Using activejob 5.1.6
       Using activerecord 5.1.6
       Using actionview 5.1.6
       Using sass 3.7.3
       Using actionpack 5.1.6
       Using actioncable 5.1.6
       Using actionmailer 5.1.6
       Using railties 5.1.6
       Using sprockets-rails 3.2.1
       Using coffee-rails 4.2.2
       Using jquery-rails 4.3.1
       Using rails 5.1.6
       Using sass-rails 5.0.6
       Installing pg 0.20.0 with native extensions
       Bundle complete! 16 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 (16.72s)
       Cleaning up the bundler cache.
       Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.17.2). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
       The latest bundler is 2.0.1, but you are currently running 1.15.2.
       To update, run `gem install bundler`
-----> Installing node-v10.14.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.69s)
       Cleaning assets
       Running: rake assets:clean
-----> Detecting rails configuration
###### WARNING:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:
       ruby '2.5.3'
       # See https://devcenter.heroku.com/articles/ruby-versions for more information.
###### WARNING:
       Detecting rails configuration failed
       set HEROKU_DEBUG_RAILS_RUNNER=1 to debug
-----> Discovering process types
       Procfile declares types     -> web
       Default types for buildpack -> console, rake
-----> Compressing...
       Done: 35.3M
-----> Launching...
       Released v9
       https://evening-headland-50906.herokuapp.com/ deployed to Heroku

放弃吧 ROR 少年

这几行有些问题

-----> Detecting rails configuration
###### WARNING:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:
       ruby '2.5.3'
       # See https://devcenter.heroku.com/articles/ruby-versions for more information.
###### WARNING:
       Detecting rails configuration failed
       set HEROKU_DEBUG_RAILS_RUNNER=1 to debug

尝试以下操作:

  1. 在 Gemfile 里面加上 ruby '2.5.3' 或者你本地开发的版本,让两个环境一致。
  2. 执行 heroku config:set HEROKU_DEBUG_RAILS_RUNNER=1,应该会触发部署,查看输出。如果没有触发就再 push 一次。
  3. 执行 heroku run bash,到一次性容器里面执行 rails c 等操作看看有什么问题。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册