Question

I am introducing wicked_pdf in my app and the generation of the pdf results very very slow.

When using thin I manage to obtain in many many minutes (more than 10) a pdf with the correct contents, but missing the css and the images.

I now switched to using unicorn with 3 workers, and the request fails after 60 seconds. So the pdf generation doesn't work at all.

here's the output from unicorn:

"***************\"/usr/local/bin/wkhtmltopdf\" -q        \"file:////var/folders/hc/yp8ps4x54rg7clpzf7g6plwm0000gq/T/wicked_pdf20140123-25990-100u2wv.html\" \"/var/folders/hc/yp8ps4x54rg7clpzf7g6plwm0000gq/T/wicked_pdf_generated_file20140123-25990-1hakql5.pdf\" ***************"
E, [2014-01-23T15:45:03.391769 #25693] ERROR -- : worker=0 PID:25990 timeout (61s > 60s), killing
E, [2014-01-23T15:45:03.399291 #25693] ERROR -- : reaped #<Process::Status: pid 25990 SIGKILL (signal 9)> worker=0
I, [2014-01-23T15:45:03.399536 #25693]  INFO -- : worker=0 spawning...
I, [2014-01-23T15:45:03.401747 #26013]  INFO -- : worker=0 spawned pid=26013
I, [2014-01-23T15:45:03.402179 #26013]  INFO -- : Refreshing Gem list
I, [2014-01-23T15:45:06.113099 #26013]  INFO -- : worker=0 ready

my show controller looks like this:

respond_to do |format|
  format.html # show.html.erb
  format.json { render json: @item }
  format.pdf do
    render pdf: "#{current_user.username.dehumanize}_item_#{@item.id}"
  end
end

and I have reduced my show.pdf.haml to:

%html
  %head
  %body
    #wrapper
      .top_wrapper
        %header.top-header.border
          .container
            .row-fluid.header
              logo
              .span2
                logo2
        .container
          .row-fluid
      .body-wrapper
        .container
          .row
            .span4
              %h4 Comments
          .row
            .span9
      %footer
Was it helpful?

Solution

I figured that the problem was wkhtmltopdf hanging after creating the pdf as a temp file.

I checked then in among the issues of wkhtmltopdf and found that this is an old known issue, which has still not been resolved.

The last working version that didn't have this problem was 0.9.9.

Here the instructions to install it via brew:

Why does PDFKit/wkhtmltopdf hang but renders PDF as expected when Rails app is killed?

here's the link to the issue as found on wkhtmltopdf:

https://code.google.com/p/wkhtmltopdf/issues/detail?id=141

OTHER TIPS

wicked_pdf is too slow and many troubles. I replaced it with this nice gem: https://github.com/Studiosity/grover .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top