【问题标题】:Server/database errors when using sinatra app on heroku在 Heroku 上使用 sinatra 应用程序时出现服务器/数据库错误
【发布时间】:2015-09-03 00:44:52
【问题描述】:

我最近使用 Postgres 数据库制作了一个示例 sinatra 应用程序,并将其部署到 heroku。使用它时,有时它会起作用,有时我会收到“内部服务器错误”。

在 heroku 日志中,错误显示为

ActiveRecord::ConnectionTimeoutError - could not obtain a database connection within 5.000 seconds.

谁能帮我解决我的问题?日志显示:

2015-06-17T15:52:41.646352+00:00 app[web.1]: 38.88.254.234 - - [17/Jun/2015 15:52:41] "GET /deck_select HTTP/1.1" 500 30 5.0016
2015-06-17T15:52:46.693209+00:00 heroku[router]: at=info method=GET path="/logout" host=calm-plains-7529.herokuapp.com request_id=cfddc08d-1598-4ec9-b9b6-774c3fac8a46 fwd="38.88.254.234" dyno=web.1 connect=1ms service=13ms status=302 bytes=549

2015-06-17T15:52:46.764409+00:00 heroku[router]: at=info method=GET path="/" host=calm-plains-7529.herokuapp.com request_id=e4103cd9-79ca-4184-9a2e-365eb6e0ba27 fwd="38.88.254.234" dyno=web.1 connect=1ms service=11ms status=200 bytes=2283

2015-06-17T15:52:46.689805+00:00 app[web.1]: 38.88.254.234 - - [17/Jun/2015 15:52:46] "GET /logout HTTP/1.1" 302 - 0.0012

2015-06-17T15:52:46.762402+00:00 app[web.1]: 38.88.254.234 - - [17/Jun/2015 15:52:46] "GET / HTTP/1.1" 200 1492 0.0012

2015-06-17T15:52:57.515297+00:00 heroku[router]: at=info method=POST path="/" host=calm-plains-7529.herokuapp.com request_id=b1f9e1ff-68af-4057-9d49-add74b8f0abd fwd="38.88.254.234" dyno=web.1 connect=1ms service=5010ms status=500 bytes=326

2015-06-17T15:52:57.512712+00:00 app[web.1]: **ActiveRecord::ConnectionTimeoutError - could not obtain a database connection within 5.000 seconds (waited 5.003 seconds):**

【问题讨论】:

    标签: ruby postgresql activerecord heroku sinatra


    【解决方案1】:

    这个错误是不言自明的。表示 PG 实例在 5 秒内没有回复。

    如果是自托管的 PG 实例,请确保 PG 服务器是可访问的。否则,如果它在 Heroku,您可能需要与他们核实一下为什么它在很短的时间内没有响应。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-15
      • 2021-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多