heroku中的wkhtmltopdf:内存问题

时间:2015-07-31 02:51:51

标签: ruby-on-rails ruby heroku wkhtmltopdf

我在Heroku的免费dyno中运行Rails 4.2.3 / Ruby 2.2.2应用程序。

我使用wkhtmltopdf-buildpack,但每次尝试生成PDF文件时,Heroku日志都会显示错误R14(超出内存配额)。这是一个例子:

2015-07-31T02:06:52.005696+00:00 app[web.1]: Started GET "/orders/1.pdf" for 200.149.16.70 at 2015-07-31 02:06:52 +0000
2015-07-31T02:06:52.162915+00:00 app[web.1]:   Rendered clients/_client.html.erb (85.3ms)
2015-07-31T02:06:52.015043+00:00 app[web.1]: Processing by OrdersController#show as PDF
2015-07-31T02:06:52.015049+00:00 app[web.1]:   Parameters: {"id"=>"1"}
2015-07-31T02:06:52.071357+00:00 app[web.1]: ***************WICKED***************
2015-07-31T02:06:52.309300+00:00 app[web.1]:   Rendered orders/_order_products.html.erb (145.6ms)
2015-07-31T02:06:52.339531+00:00 app[web.1]:   Rendered orders/show.html.erb (267.2ms)
2015-07-31T02:06:52.339015+00:00 app[web.1]:   Rendered orders/_order.html.erb (262.6ms)
2015-07-31T02:07:12.162183+00:00 heroku[web.1]: Process running mem=662M(129.4%)
2015-07-31T02:07:12.162183+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2015-07-31T02:07:22.005012+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/orders/1.pdf" host=app.herokuapp.com request_id=50f6840e-1907-4730-ab0d-1a6f415eb3db fwd="200.*.*.*" dyno=web.1 connect=3ms service=30001ms status=503 bytes=0

我曾在wkhtmltopdf-heroku gem之前尝试过,但我遇到了同样的内存问题。 我不确定如何调试此问题,但您能帮忙吗?在这种情况下添加dynos是一个选项吗?

1 个答案:

答案 0 :(得分:1)

解决:我使用gem wkhtmltopdf-binary解决了这个问题。我也尝试过gem wkhtmltopdf-heroku,但这并没有用。