在heroku上成功部署了app,但在浏览器中显示了Application Error

时间:2014-09-19 22:48:16

标签: ruby-on-rails ruby heroku railstutorial.org

我正在按照Michael Hartl的Rails教程使用ruby on rails构建一个应用程序。 我尝试在heroku上部署应用程序,显然我没有遇到任何问题,但是一旦我在heroku上打开应用程序,它就会向我显示应用程序错误。我几乎无能为力......这是日志文件:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-1.9.3
###### WARNING:
       Removing `Gemfile.lock` because it was generated on Windows.
       Bundler will do a full resolve so native gems are handled properly.
       This may result in unexpected gem versions being used in your app.
       In rare occasions Bundler may not be able to resolve your dependencies at all.
       https://devcenter.heroku.com/articles/bundler-windows-gemfile

-----> Installing dependencies using 1.6.3
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4
       Your Gemfile lists the gem rspec-rails (>= 0) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem jquery-rails (= 3.0.4) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem pg (= 0.15.1) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem rails_12factor (= 0.0.2) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Fetching git://github.com/bmabey/database_cleaner.git
       Fetching gem metadata from https://rubygems.org/.........
       Resolving dependencies...
       Using rake 10.3.2
       Using i18n 0.6.11
       Using minitest 4.7.5
       Using thread_safe 0.3.4
       Using multi_json 1.10.1
       Using tzinfo 0.3.41
       Using builder 3.1.4
       Using erubis 2.7.0
       Using mime-types 1.25.1
       Using rack 1.5.2
       Using polyglot 0.3.5
       Using activerecord-deprecated_finders 1.0.3
       Using arel 4.0.2
       Using bcrypt-ruby 3.1.2
       Using sass 3.4.4
       Using will_paginate 3.0.4
       Using bundler 1.6.3
       Using coffee-script-source 1.8.0
       Using execjs 2.2.1
       Using hike 1.2.3
       Using thor 0.19.1
       Using json 1.8.1
       Using pg 0.15.1
       Using tilt 1.4.1
       Using rails_serve_static_assets 0.0.2
       Using rails_stdout_logging 0.0.3
       Using faker 1.1.2
       Using activesupport 4.0.2
       Using treetop 1.4.15
       Using rack-test 0.6.2
       Using bootstrap-will_paginate 0.0.9
       Using bootstrap-sass 2.3.2.0
       Using coffee-script 2.3.0
       Using rdoc 3.12.2
       Using uglifier 2.1.1
       Using rails_12factor 0.0.2
       Using sprockets 2.10.1
       Using actionpack 4.0.2
       Using activemodel 4.0.2
       Using jbuilder 1.0.2
       Using mail 2.5.4
       Using sdoc 0.3.20
       Using railties 4.0.2
       Using sprockets-rails 2.0.1
       Using actionmailer 4.0.2
       Using activerecord 4.0.2
       Using coffee-rails 4.0.1
       Using jquery-rails 3.0.4
       Using sass-rails 4.0.1
       Using rails 4.0.2
       Using turbolinks 1.1.1
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Bundle completed (8.32s)
       Cleaning up the bundler cache.
       Your Gemfile lists the gem rspec-rails (>= 0) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem jquery-rails (= 3.0.4) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem pg (= 0.15.1) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem rails_12factor (= 0.0.2) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
-----> Writing config/database.yml to read from DATABASE_URL
       Detected manifest file, assuming assets were compiled locally

###### WARNING:
       Removing `Gemfile.lock` because it was generated on Windows.
       Bundler will do a full resolve so native gems are handled properly.
       This may result in unexpected gem versions being used in your app.
       In rare occasions Bundler may not be able to resolve your dependencies at all.
       https://devcenter.heroku.com/articles/bundler-windows-gemfile

-----> Discovering process types
       Procfile declares types -> web
       Default types for Ruby  -> console, rake, worker

-----> Compressing... done, 23.0MB
-----> Launching... done, v27
       http://guarded-shelf-9628.herokuapp.com/ deployed to Heroku

将它与之前成功部署的日志进行比较后,我发现了一点点差异。在此日志中显示Default types for ruby -> console, rake, worker,而在成功部署的其他日志中显示Default types for ruby -> console, rake, web, worker,因此可能缺少网络,可能会导致问题...认为这可能是问题?如果那就是问题......我不知道如何解决这个问题! :)很想听到能帮助我的人的消息!非常感谢提前!

以下是可能提供错误信息的日志:

2014-09-19T22:58:43.981295+00:00 app[web.1]:
2014-09-19T22:58:43.981299+00:00 app[web.1]: `config/application.rb` file and an
y `mass_assignment_sanitizer` options
2014-09-19T22:58:43.981302+00:00 app[web.1]:
2014-09-19T22:58:43.981294+00:00 app[web.1]: params or add `protected_attributes
` to your Gemfile to use the old one.
2014-09-19T22:58:43.981300+00:00 app[web.1]: from your `config/environments/*.rb
` files.
2014-09-19T22:58:43.981330+00:00 app[web.1]:
2014-09-19T22:58:44.252040+00:00 app[web.1]: A server is already running. Check
/app/tmp/pids/server.pid.
2014-09-19T22:58:44.252144+00:00 app[web.1]: => Run `rails server -h` for more s
tartup options
2014-09-19T22:58:44.252142+00:00 app[web.1]: => Rails 4.0.2 application starting
 in production on http://0.0.0.0:23779
2014-09-19T22:58:44.252140+00:00 app[web.1]: => Booting WEBrick
2014-09-19T22:58:44.252145+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-09-19T22:58:44.252147+00:00 app[web.1]: Exiting
2014-09-19T22:58:45.031535+00:00 heroku[web.1]: State changed from starting to c
rashed
2014-09-19T22:58:45.020850+00:00 heroku[web.1]: Process exited with status 1
2014-09-19T23:00:06.776445+00:00 heroku[api]: Starting process with command `bun
dle exec rake db:migrate` by xxxxxxxx@hotmail.com
2014-09-19T23:00:09.905857+00:00 heroku[run.8558]: Awaiting client
2014-09-19T23:00:09.944483+00:00 heroku[run.8558]: Starting process with command
 `bundle exec rake db:migrate`
2014-09-19T23:00:10.286566+00:00 heroku[run.8558]: State changed from starting t
o up
2014-09-19T23:00:15.233196+00:00 heroku[run.8558]: State changed from up to comp
lete
2014-09-19T23:00:15.217870+00:00 heroku[run.8558]: Process exited with status 0
2014-09-19T23:09:00.021083+00:00 heroku[web.1]: State changed from crashed to st
arting
2014-09-19T23:09:06.045524+00:00 heroku[web.1]: Starting process with command `b
undle exec rails server -p 52238`
2014-09-19T23:09:08.517868+00:00 app[web.1]: Your Gemfile lists the gem rspec-ra
ils (>= 0) more than once.
2014-09-19T23:09:08.525341+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:08.525343+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:08.517884+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:08.517887+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:08.518722+00:00 app[web.1]: Your Gemfile lists the gem jquery-r
ails (= 3.0.4) more than once.
2014-09-19T23:09:08.535911+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:08.535913+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:08.518726+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:08.518728+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:08.525337+00:00 app[web.1]: Your Gemfile lists the gem pg (= 0.
15.1) more than once.
2014-09-19T23:09:08.535904+00:00 app[web.1]: Your Gemfile lists the gem rails_12
factor (= 0.0.2) more than once.
2014-09-19T23:09:16.478210+00:00 app[web.1]: DEPRECATION WARNING: config.whiny_n
ils option is deprecated and no longer works. (called from block in <top (requir
ed)> at /app/config/environments/production.rb:6)
2014-09-19T23:09:16.602557+00:00 app[web.1]:
2014-09-19T23:09:16.602552+00:00 app[web.1]: config.eager_load is set to nil. Pl
ease update your config/environments/*.rb files accordingly:
2014-09-19T23:09:16.602560+00:00 app[web.1]:   * development - set it to false
2014-09-19T23:09:16.602561+00:00 app[web.1]:   * test - set it to false (unless
you use a tool that preloads your test environment)
2014-09-19T23:09:16.602563+00:00 app[web.1]:   * production - set it to true
2014-09-19T23:09:16.602564+00:00 app[web.1]:
2014-09-19T23:09:16.602588+00:00 app[web.1]:
2014-09-19T23:09:18.980362+00:00 app[web.1]: DEPRECATION WARNING: Model based ma
ss assignment security has been extracted
2014-09-19T23:09:18.980372+00:00 app[web.1]:
2014-09-19T23:09:18.980380+00:00 app[web.1]: See http://guides.rubyonrails.org/s
ecurity.html#mass-assignment for more information.
2014-09-19T23:09:18.980375+00:00 app[web.1]: `config/application.rb` file and an
y `mass_assignment_sanitizer` options
2014-09-19T23:09:18.980378+00:00 app[web.1]:
2014-09-19T23:09:18.980374+00:00 app[web.1]: To disable this message remove the
`whitelist_attributes` option from your
2014-09-19T23:09:18.980377+00:00 app[web.1]: from your `config/environments/*.rb
` files.
2014-09-19T23:09:18.980406+00:00 app[web.1]:
2014-09-19T23:09:18.980370+00:00 app[web.1]: params or add `protected_attributes
` to your Gemfile to use the old one.
2014-09-19T23:09:18.980368+00:00 app[web.1]: out of Rails into a gem. Please use
 the new recommended protection model for
2014-09-19T23:09:19.458144+00:00 app[web.1]: => Rails 4.0.2 application starting
 in production on http://0.0.0.0:52238
2014-09-19T23:09:19.458184+00:00 app[web.1]: Exiting
2014-09-19T23:09:19.458145+00:00 app[web.1]: => Run `rails server -h` for more s
tartup options
2014-09-19T23:09:19.458147+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-09-19T23:09:19.458138+00:00 app[web.1]: => Booting WEBrick
2014-09-19T23:09:19.450797+00:00 app[web.1]: A server is already running. Check
/app/tmp/pids/server.pid.
2014-09-19T23:09:20.395099+00:00 heroku[web.1]: Process exited with status 1
2014-09-19T23:09:20.407213+00:00 heroku[web.1]: State changed from starting to c
rashed
2014-09-19T23:09:20.407904+00:00 heroku[web.1]: State changed from crashed to st
arting
2014-09-19T23:09:24.294382+00:00 heroku[web.1]: Starting process with command `b
undle exec rails server -p 11906`
2014-09-19T23:09:26.659179+00:00 app[web.1]: Your Gemfile lists the gem rspec-ra
ils (>= 0) more than once.
2014-09-19T23:09:26.659198+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:26.659196+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:26.659738+00:00 app[web.1]: Your Gemfile lists the gem jquery-r
ails (= 3.0.4) more than once.
2014-09-19T23:09:26.659743+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:26.659741+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:26.664097+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:26.664091+00:00 app[web.1]: Your Gemfile lists the gem pg (= 0.
15.1) more than once.
2014-09-19T23:09:26.664325+00:00 app[web.1]: Your Gemfile lists the gem rails_12
factor (= 0.0.2) more than once.
2014-09-19T23:09:26.664099+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:26.664328+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:26.664330+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:28.647892+00:00 app[web.1]: DEPRECATION WARNING: config.whiny_n
ils option is deprecated and no longer works. (called from block in <top (requir
ed)> at /app/config/environments/production.rb:6)
2014-09-19T23:09:28.717340+00:00 app[web.1]: config.eager_load is set to nil. Pl
ease update your config/environments/*.rb files accordingly:
2014-09-19T23:09:28.717344+00:00 app[web.1]:
2014-09-19T23:09:28.717346+00:00 app[web.1]:   * development - set it to false
2014-09-19T23:09:28.717347+00:00 app[web.1]:   * test - set it to false (unless
you use a tool that preloads your test environment)
2014-09-19T23:09:28.717349+00:00 app[web.1]:   * production - set it to true
2014-09-19T23:09:28.717350+00:00 app[web.1]:
2014-09-19T23:09:28.717352+00:00 app[web.1]:
2014-09-19T23:09:29.932824+00:00 app[web.1]: DEPRECATION WARNING: Model based ma
ss assignment security has been extracted
2014-09-19T23:09:29.932830+00:00 app[web.1]: out of Rails into a gem. Please use
 the new recommended protection model for
2014-09-19T23:09:29.932831+00:00 app[web.1]: params or add `protected_attributes
` to your Gemfile to use the old one.
2014-09-19T23:09:29.932833+00:00 app[web.1]:
2014-09-19T23:09:30.174451+00:00 app[web.1]: => Run `rails server -h` for more s
tartup options
2014-09-19T23:09:29.932835+00:00 app[web.1]: To disable this message remove the
`whitelist_attributes` option from your
2014-09-19T23:09:29.932838+00:00 app[web.1]: from your `config/environments/*.rb
` files.
2014-09-19T23:09:29.932836+00:00 app[web.1]: `config/application.rb` file and an
y `mass_assignment_sanitizer` options
2014-09-19T23:09:29.932842+00:00 app[web.1]:
2014-09-19T23:09:29.932839+00:00 app[web.1]:
2014-09-19T23:09:30.174417+00:00 app[web.1]: A server is already running. Check
/app/tmp/pids/server.pid.
2014-09-19T23:09:30.174453+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-09-19T23:09:29.932841+00:00 app[web.1]: See http://guides.rubyonrails.org/s
ecurity.html#mass-assignment for more information.
2014-09-19T23:09:30.174447+00:00 app[web.1]: => Booting WEBrick
2014-09-19T23:09:30.174454+00:00 app[web.1]: Exiting
2014-09-19T23:09:30.174450+00:00 app[web.1]: => Rails 4.0.2 application starting
 in production on http://0.0.0.0:11906
2014-09-19T23:09:31.093052+00:00 heroku[web.1]: State changed from starting to c
rashed
2014-09-19T23:09:31.072183+00:00 heroku[web.1]: Process exited with status 1
2014-09-19T23:09:33.082176+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=guarded-shelf-9628.herokuapp.com request_id=fae64
19e-d8ca-498f-ab94-936295266fe4 fwd="190.195.118.32" dyno= connect= service= sta
tus=503 bytes=

2 个答案:

答案 0 :(得分:1)

对于每个有兴趣的人......经过几个小时的尝试,我终于能够解决它了!

所以问题是我的 server.pid 文件有什么问题...而不是数字,在我的主分支中它只有一行文字说“注册”看起来像非常奇怪,所以我去了我正在处理的前一个分支,复制了server.pid文件的内容并将其粘贴到master分支中的一个,提交并推送到heroku,现在应用程序运行顺利! :)

非常感谢所有贡献的人!

答案 1 :(得分:0)

错误

Heroku有两种类型的错误 - 平台错误和语法(Rails)错误:

-

<强>平台

enter image description here

第一个问题是平台错误

这是Heroku级别,基本上意味着你的&#34;系统&#34; (平台)无法正常运行。要么您的依赖项丢失/损坏,要么平台配置不正确。

大多数案例中,显示的原因是因为您没有引用正确的数据库 - 导致您的应用甚至无法启动。我将在下面解释如何解决这个问题

-

<强>语法

enter image description here

这是一个 Rails 问题 - 意味着你所有的&#34;平台&#34;水平技术将正常工作。如果你遇到其中一个错误,它基本上意味着你的Rails应用程序本身存在某种问题(不仅仅是它运行的平台)

接收此类错误基本上意味着您必须更正代码(而非平台)的问题。虽然这可能意味着依赖


<强>修正

从你的错误中可以看出,Heroku存在问题,而且不太可能是rails。为此,我建议如下:

  
      
  1. 检查应用的数据库配置
  2.   
  3. 检查它是否已正确迁移
  4.   
  5. 检查是否所有内容都已更新&amp;运行依赖项
  6.   

首先,最重要的是,您需要确保您拥有&#34;生产&#34;在Heroku * 中分配的数据库。虽然您可以使用任何数据库,但您最好使用Heroku的板载PGSQL setup - 如果从Heroku仪表板安装,应该使您的应用程序能够运行生产数据库< / p>

其次,您需要迁移到该数据库。您可以通过在本地开发系统中运行heroku run rake db:migrate来完成此操作 - 这将填充上述数据库

最后,您要确保Heroku具有所有相应的依赖关系等。这是通过附加组件完成的,并且完全诚实,在您的问题中不太可能出现(非常罕见)