wicked-pdf hangs server when generating file
Asked Answered
A

1

6

On a rails 3.2.18 application, with wicked_pdf (0.11.0) and wkhtmltopdf-binary (0.9.9.3) declared in the gem file, mime-types.rb was not amended to includeMime::Type.register "application/pdf", :pdf otherwise, on startup of Thin on osX development platform, the following warning is given:

/Users/it/.rvm/gems/ruby-1.9.3-p125@app/gems/actionpack-3.2.18/lib/action_dispatch/http/mime_type.rb:102: warning: already initialized constant PDF

An initializer states

WickedPdf.config = {
  :exe_path => '/usr/local/bin/wkhtmltopdf'
}

The path /usr/local/bin does include an alias to wkhtmltopdf. In a show view:

  def show
    @transaction = Transaction.find(params[:id])

    respond_to do |format|
      format.html { render :layout => 'pdf' } # show.html.erb
      format.pdf do
        render :pdf => "invoice_name"
      end
      format.json { render json: @transaction }
    end
  end

The show view renders appropriately. Append the path with .pdf and the console registers:

"***************[\"/usr/local/bin/wkhtmltopdf\", \"-q\", \"file:///var/folders/kV/kVDOSPkcEuqSVnTjenAVRE+++TI/-Tmp-/wicked_pdf20141018-1401-m614pd.html\", \"/var/folders/kV/kVDOSPkcEuqSVnTjenAVRE+++TI/-Tmp-/wicked_pdf_generated_file20141018-1401-1hor23g.pdf\"]***************"

And the server hangs. It gets interrupted with ctrl-c and then the server console adds:

[...]
Rendered transactions/show.pdf.erb (12.1ms)
Rendered text template (0.0ms)
Sent data invoice_name.pdf  (18.8ms)
Completed 200 OK in 36322.7ms (Views: 15.2ms | ActiveRecord: 3.0ms)
Exiting

which it did not do. Other attempts to simply generate a file and save it have led to non-production of the PDF file, but without hanging the Thin server. So the engines are not all running properly...

What is wrong with the set-up?

Alphonse answered 18/10, 2014 at 12:0 Comment(0)
A
5

Recalling having run successfully wicked-pdf in the past, the answer to what is different provided the solution: removing the initializer allows the process to run its course.

Alphonse answered 18/10, 2014 at 13:8 Comment(2)
You ever find a solution @jerome? Having the same issue.Lindahl
In my case, as I stated, I had an initializer, that exe_path, which gummed things up. I recalled I had just added that and thus attempted removing it. The process ran its expected course and thus the problem was with that initializer. I admit it is not a good explanation, just a pointer to the guilty party.Alphonse

© 2022 - 2024 — McMap. All rights reserved.