在heroku上使用sinatra app时出现服务器/数据库错误

时间:2015-06-17 16:34:05

标签: ruby postgresql activerecord heroku sinatra

我最近使用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):**

1 个答案:

答案 0 :(得分:0)

错误很明显。这意味着PG实例在5秒内没有回复。

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