3

我的 pdf 在本地正确生成,有时在我的 Heroku 应用程序中生成,但有时它们会超时,我会看到这个错误

2012-05-04T14:53:33+00:00 app[web.1]: Started GET "/orders/125/invoice_pdf.pdf" for 10.87.41.73 at 2012-05-04 14:53:33 +0000
2012-05-04T14:54:03+00:00 heroku[router]: Error H12 (Request timeout) -> GET www.printavo.com/orders/125/invoice_pdf.pdf dyno=web.1 queue= wait= service=30000ms status=503 bytes=0
2012-05-04T14:54:03+00:00 heroku[nginx]: 10.87.41.73 - backerm2 [04/May/2012:14:54:03 +0000] "GET /orders/125/invoice_pdf.pdf HTTP/1.1" 503 607 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19" www.printavo.com
2012-05-04T14:54:03+00:00 heroku[nginx]: 127.0.0.1 - backerm2 [04/May/2012:14:54:03 +0000] "GET /orders/125/invoice_pdf.pdf HTTP/1.0" 503 607 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19" www.printavo.com
2012-05-04T14:54:05+00:00 heroku[router]: Error H12 (Request timeout) -> GET www.printavo.com/customers/new dyno=web.1 queue= wait= service=30000ms status=503 bytes=0

知道有什么问题吗?

4

2 回答 2

0

经过进一步审查。您不需要 2 个网络测功机。只需确保将 CSS 包含在 application.html.erb 文件夹和您的 file_name.pdf.erb 中即可。

这是我的 application.html.erb 文件。

<% if request_from_pdfkit? %>
            <!-- css for pdf -->
                <style type="text/css">
                    <%= File.read(Rails.root.join("public","stylesheets","invoice_pdf.css.scss"))%>
                    <%= File.read(Rails.root.join("public","stylesheets","app.css.scss"))%>
                </style>
            <% end %>

任何然后我的 .pdf.erb 文件

<!DOCTYPE html>
<html>
<head>
  <title><%= title %></title>
    <style type="text/css">
        <%= Printavo::Application.assets["invoice_pdf.css.scss"].to_s.html_safe %>
        <%= Printavo::Application.assets["app.css.scss"].to_s.html_safe %>
        body{ font-family: arial !important;}
    </style>
</head>
于 2012-11-28T18:04:47.503 回答
0

2 web dynos 修复了这个问题或者使用了delayed_jobs gem。还要确保在生成的 PDF 中包含 CSS。

于 2012-11-13T16:32:08.407 回答