Rails 4.1.6部署时的Heroku应用程序错误

时间:2014-10-11 17:20:52

标签: ruby postgresql heroku unicorn ruby-on-rails-4.1

我已经尝试过我能想到的一切或Google。我无法理解为什么我的Rails应用程序不会在Heroku上部署。

我已经从WebBrick切换到Unicorn服务器,该服务器在本地工作正常。 也从SQLite3转换为PostgrSQL。运行rake db:create / migrate。销毁并创建了一个新的Heroku存储库。

Heroku接受推送但是当我尝试部署应用程序时,我不断收到此错误消息:

Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

我整天都难过!我已经阅读了显示很多问题的日志(我猜),但我看不到解决方案。不太确定要找什么......

任何线索都会非常感激。非常感谢!

2014-10-11T12:44:13.004608+00:00 heroku[api]: Release v2 created by 
2014-10-11T12:44:13.004608+00:00 heroku[api]: Enable Logplex by 
2014-10-11T16:45:10+00:00 heroku[slug-compiler]: Slug compilation started
2014-10-11T16:46:00.915135+00:00 heroku[api]: Scale to web=1 by 
2014-10-11T16:46:01.352660+00:00 heroku[api]: Set DATABASE_URL config vars by 
2014-10-11T16:46:01.352739+00:00 heroku[api]: Release v3 created by 
2014-10-11T16:46:01.484781+00:00 heroku[api]: Attach HEROKU_POSTGRESQL_CHARCOAL resource by 
2014-10-11T16:46:01.484841+00:00 heroku[api]: Release v4 created by 
2014-10-11T16:46:01.709332+00:00 heroku[api]: Release v5 created by 
2014-10-11T16:46:01.709249+00:00 heroku[api]: Set LANG, RAILS_ENV, RACK_ENV, SECRET_KEY_BASE config vars by 
2014-10-11T16:46:01+00:00 heroku[slug-compiler]: Slug compilation finished
2014-10-11T16:46:01.816634+00:00 heroku[api]: Deploy 1b095c7 by 
2014-10-11T16:46:01.816710+00:00 heroku[api]: Release v6 created by 
2014-10-11T16:46:06.300267+00:00 heroku[web.1]: Starting process with command `bundle exec rails server thin -c ./config/unicorn.rb`
2014-10-11T16:46:08.829526+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/server.rb:112:in `print_boot_information'
2014-10-11T16:46:08.829515+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/thin.rb:1:in `<top (required)>'
2014-10-11T16:46:08.829492+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/thin.rb:1:in `require': cannot load such file -- thin (LoadError)
2014-10-11T16:46:08.829523+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `get'
2014-10-11T16:46:08.829528+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/server.rb:64:in `start'
2014-10-11T16:46:08.829525+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:268:in `server'
2014-10-11T16:46:08.829532+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:81:in `block in server'
2014-10-11T16:46:08.829533+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `tap'
2014-10-11T16:46:08.829535+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `server'
2014-10-11T16:46:08.829537+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
2014-10-11T16:46:08.829538+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands.rb:17:in `<top (required)>'
2014-10-11T16:46:08.829540+00:00 app[web.1]:    from bin/rails:8:in `require'
2014-10-11T16:46:08.829541+00:00 app[web.1]:    from bin/rails:8:in `<main>'
2014-10-11T16:46:08.852393+00:00 app[web.1]: Exiting
2014-10-11T16:46:08.829519+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `block in get'
2014-10-11T16:46:08.829522+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `inject'
2014-10-11T16:46:08.829520+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `each'
2014-10-11T16:46:08.829517+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `const_get'
2014-10-11T16:46:09.693591+00:00 heroku[web.1]: Process exited with status 1
2014-10-11T16:46:09.703135+00:00 heroku[web.1]: State changed from starting to crashed
2014-10-11T16:46:09.703788+00:00 heroku[web.1]: State changed from crashed to starting
2014-10-11T16:46:12.622337+00:00 heroku[web.1]: Starting process with command `bundle exec rails server thin -c ./config/unicorn.rb`
2014-10-11T16:46:14.793857+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:81:in `block in server'
2014-10-11T16:46:14.793818+00:00 app[web.1]: /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/thin.rb:1:in `require': cannot load such file -- thin (LoadError)
2014-10-11T16:46:14.793839+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/thin.rb:1:in `<top (required)>'
2014-10-11T16:46:14.793843+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `block in get'
2014-10-11T16:46:14.793841+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `const_get'
2014-10-11T16:46:14.793844+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `each'
2014-10-11T16:46:14.793846+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `inject'
2014-10-11T16:46:14.793850+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler.rb:20:in `get'
2014-10-11T16:46:14.793852+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/server.rb:268:in `server'
2014-10-11T16:46:14.793854+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/server.rb:112:in `print_boot_information'
2014-10-11T16:46:14.793855+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/server.rb:64:in `start'
2014-10-11T16:46:14.793859+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `tap'
2014-10-11T16:46:14.793861+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `server'
2014-10-11T16:46:14.793862+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
2014-10-11T16:46:14.793864+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/railties-4.1.6/lib/rails/commands.rb:17:in `<top (required)>'
2014-10-11T16:46:14.793866+00:00 app[web.1]:    from bin/rails:8:in `require'
2014-10-11T16:46:14.793867+00:00 app[web.1]:    from bin/rails:8:in `<main>'
2014-10-11T16:46:14.813606+00:00 app[web.1]: Exiting
2014-10-11T16:46:15.541599+00:00 heroku[web.1]: State changed from starting to crashed
2014-10-11T16:46:15.535072+00:00 heroku[web.1]: Process exited with status 1
2014-10-11T16:46:17.156358+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=guarded-sierra-8698.herokuapp.com request_id=fc23f5aa-1ad0-4b97-8c59-d2560868bd92 fwd="54.161.120.115" dyno= connect= service= status=503 bytes=
2014-10-11T16:46:29.378778+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=guarded-sierra-8698.herokuapp.com request_id=8c0751d6-7ac7-4327-977e-0ca239efbbfe fwd="86.136.228.226" dyno= connect= service= status=503 bytes=
2014-10-11T16:46:29.659854+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=guarded-sierra-8698.herokuapp.com request_id=86550a2e-c9ca-4470-b2ea-7d4cd4a9fd63 fwd="86.136.228.226" dyno= connect= service= status=503 bytes=

1 个答案:

答案 0 :(得分:0)

问题已解决。所有3个人!

  1. 我的Procfile设置为使用瘦服务器而不是独角兽:

    + web:bundle exec rails server thin -c ./config/unicorn.rb

  2. 我误读了之前的Stack Overflow帖子并将其设置为。

    1. gem thin和它的2个依赖项(gem eventmachine&amp; gem daemons)不在我的.Gemfile或bundle中,导致此错误消息崩溃:

      /app/vendor/bundle/ruby/2.1.0/gems/rack-1.5.2/lib/rack/handler/thin.rb:1:in`requirent':无法加载此类文件 - 瘦(LoadError) )

    2. 即使一切顺利,Heroku也不会显示rails默认目标网页。您必须在路线中指定“欢迎”页面,否则会引发404错误。

    3. 解决方案

      1. 我安装并捆绑了瘦gem及其依赖项。这修复了上面的初始崩溃错误,但没有解决我的问题,因为我仍在使用错误的服务器。

      2. 我更正了我的Procfile以使用unicorn服务器:

        + web:bundle exec unicorn -p $ PORT -c ./config/unicorn.rb

      3. 我设置了一个“欢迎”控制器并路由到一个非常基本的“Hello World”欢迎页面,其中包含一个时间戳:

        Hello World

          就是现在:

      4. 现在所有人都在Heroku上完美展现!

        接下来,我将尝试删除精简的gem和依赖项。希望他们是一个红鲱鱼,一切都应该工作正常。虽然一步一步。我现在不想破坏它现在它和它工作

        希望这对所有人都有帮助!