在本地工作时获取Heroku h10错误

时间:2016-04-29 01:55:03

标签: ruby-on-rails heroku

目前我收到一个h10应用程序崩溃错误,即使它在本地工作,日志似乎没有帮助。该日志首先出现错误

  

错误R10(启动超时) - > Web进程无法绑定到$ PORT   在错误代码= H10处获得错误之前60秒启动   desc =" App崩溃" method = GET path =" /favicon.ico"   主机= maitri-compassionate-care-app.herokuapp.com   request_id = 602ed7f2-118f-43b2-b57f-077b89c7b2c4 fwd =" 98.248.251.49"   dyno = connect = service = status = 503 bytes =

这是日志:

2016-04-29T01:44:39.917289+00:00 heroku[slug-compiler]: Slug compilation started
2016-04-29T01:44:39.917299+00:00 heroku[slug-compiler]: Slug compilation finished
2016-04-29T01:44:41.023311+00:00 heroku[web.1]: State changed from crashed to starting
2016-04-29T01:44:43.205739+00:00 heroku[web.1]: Starting process with command `bundle exec rails s`
2016-04-29T01:44:46.498256+00:00 app[web.1]: DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in <top (required)> at /app/config/environments/production.rb:2)
2016-04-29T01:44:46.880147+00:00 app[web.1]: [2016-04-29 01:44:46] INFO  WEBrick 1.3.1
2016-04-29T01:44:46.880438+00:00 app[web.1]: [2016-04-29 01:44:46] INFO  WEBrick::HTTPServer#start: pid=3 port=3000
2016-04-29T01:44:46.880180+00:00 app[web.1]: [2016-04-29 01:44:46] INFO  ruby 2.2.2 (2015-04-13) [x86_64-linux]
2016-04-29T01:45:43.548293+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-04-29T01:45:43.548293+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-04-29T01:45:44.291920+00:00 heroku[web.1]: Process exited with status 137
2016-04-29T01:45:44.312346+00:00 heroku[web.1]: State changed from starting to crashed
2016-04-29T01:45:48.319822+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=maitri-compassionate-care-app.herokuapp.com request_id=242958be-0403-4b41-aec9-c2d1603630a2 fwd="98.248.251.49" dyno= connect= service= status=503 bytes=
2016-04-29T01:45:48.178954+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=maitri-compassionate-care-app.herokuapp.com request_id=ae7f2a3a-d65e-4829-84b6-74c178e2973d fwd="98.248.251.49" dyno= connect= service= status=503 bytes=
2016-04-29T01:45:49.055039+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=maitri-compassionate-care-app.herokuapp.com request_id=602ed7f2-118f-43b2-b57f-077b89c7b2c4 fwd="98.248.251.49" dyno= connect= service= status=503 bytes=

我已经尝试过heroku restart,heroku ps restart,以及rake rails update bin但是它们似乎都没有帮助。除了超时和崩溃之外,我不确定如何获得更具体的错误。

由于

2 个答案:

答案 0 :(得分:1)

您的应用看起来像是使用WEBrick作为网络服务器。这适用于本地开发环境,但不应在生产环境中使用,例如部署到Heroku时。

Heroku建议使用puma作为生产服务器。详细说明可以在他们的开发中心文档中找到。

https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server

答案 1 :(得分:1)

来自Heroku docs:

  

在Common Runtime中,web dyno必须在启动后60秒内绑定到其指定的$PORT。如果没有,则由dyno管理器终止,并记录R10 Boot Timeout错误。进程可以在绑定到$PORT之前和之后绑定到其他端口。

根据您的日志,WEBrick在端口3000而不是$PORT上运行,使$PORT未绑定以延迟60秒超时。必须将WEBrick配置为在Heroku分配的端口$PORT上启动。你可以使用Procfile。

创建一个名为Procfile的{​​{1}},其名称如下:

web: bundle exec rails server -p $PORT

然后(来自文档):

  

要让Heroku使用您的Procfile,请将Procfile添加到应用程序的根目录,然后推送到Heroku:

$ git add .
$ git commit -m "Procfile"
$ git push heroku