Open timasingh opened 9 years ago
You are hitting the rescue on this line:
https://github.com/mileszs/wicked_pdf/blob/0.9.10/lib/wicked_pdf.rb#L78
You could open the gem source file (at /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/wicked_pdf-0.9.10/lib/wicked_pdf.rb), and try commenting out lines 78 and 79, reproduce the issue, and see what exception is actually being raised to give you a clue to what is happening in your setup.
I see you are generating the pdfs in a worker job through Resque. If one job begins before the other is finished, wkthmtopdf
will try to spawn Xvfb on the same display, which will fail if you already have one running.
You might need to specify the --auto-servernum --server-num=1
parameters to xvfb-run. I see you already have the shorthand argument, -a
, but I've seen reported success by specifying the --server-num=1
.
You could also try upgrading wicked_pdf. 0.11.0 is the latest official release, however many people have been running against master, which works better with newer releases of wkhtmltopdf
(that are not backward compatible in syntax).
You can run against master by adding this to your Gemfile in place of your existing wicked_pdf and wkhtmltopdf gems:
gem 'wicked_pdf', github: 'mileszs/wicked_pdf'
gem 'wkhtmltopdf-binary-edge', '~> 0.12.2.1'
Let me know how it goes!
Thanks.
We have specified the number of worker
as 1
and commented 78 and 79 lines. Still we could not able to reproduce the issue in lower environments.
we have upgraded the wicked_pdf gem
alone. we are using centos
so omitted gem 'wkhtmltopdf-binary-edge', '~> 0.12.2.1'
.
Will let you the outcome of upgrade.
Any updates on this? I am using the following versions, and also getting the exact same error mentioned here. wicked_pdf (1.4.0) wkhtmltopdf-binary (0.12.4)
Any news? Facing the same issue.
Hi all
I am using wicked PDF gem version 0.9 for generating HTML to PDF , We have seen massive numbers of errors in all our environment , where PDF is not generated and throws the below error Also i can confirm this happens only in 20 % of the cases, we have a ticket booking system so out of 100 tickets being booked there may be ~10/20 incidences when ticket is not being generated and we get the error
Errror:
A RuntimeError occurred in background at 2015-08-20 20:35:59 +0100 : Failed to execute: “/usr/local/bin/wkhtmltopdf” -q "file:////tmp/wicked_pdf20150820-22625-1ydsjt2.html" “/tmp/wicked_pdf_generated_file20150820-22625-ebglcw.pdf” Error: PDF could not be generated! Command Error: xvfb-run -a -s “-screen 0, 1024x768x24” wkhtmltopdf.bin $* + xvfb-run -a -s ‘-screen 0, 1024x768x24’ wkhtmltopdf.bin -q file:////tmp/wicked_pdf20150820-22625-1ydsjt2.html /tmp/wicked_pdf_generated_file20150820-22625-ebglcw.pdf
/var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/wicked_pdf-0.9.10/lib/wicked_pdf.rb:79:in `rescue in pdf_from_string'
Backtrace: /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/wicked_pdf-0.9.10/lib/wicked_pdf.rb:79:in
rescue in pdf_from_string' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/wicked_pdf-0.9.10/lib/wicked_pdf.rb:83:in
pdf_from_string' /var/application/nus/nusdigital/app/mailers/event_booking_mailer.rb:38:innotify_event_booking' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:167:in
process_action' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:121:inprocess' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in
process' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:459:inprocess' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/actionmailer-3.2.13/lib/action_mailer/base.rb:453:in
initialize' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque_mailer-2.2.4/lib/resque_mailer.rb:48:innew' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque_mailer-2.2.4/lib/resque_mailer.rb:48:in
perform' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque-1.25.0/lib/resque/job.rb:240:inblock (3 levels) in perform' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.9.0.229/lib/new_relic/agent/instrumentation/resque.rb:40:in
block in around_perform_with_monitoring' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.9.0.229/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:364:inperform_action_with_newrelic_trace' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/newrelic_rpm-3.9.0.229/lib/new_relic/agent/instrumentation/resque.rb:34:in
around_perform_with_monitoring' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque-1.25.0/lib/resque/job.rb:239:inblock (2 levels) in perform' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque-1.25.0/lib/resque/job.rb:247:in
call' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque-1.25.0/lib/resque/job.rb:247:inperform' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque-1.25.0/lib/resque/worker.rb:250:in
perform' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque-1.25.0/lib/resque/worker.rb:189:inblock in work' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque-1.25.0/lib/resque/worker.rb:166:in
loop' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque-1.25.0/lib/resque/worker.rb:166:inwork' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/resque-1.25.0/lib/resque/tasks.rb:41:in
block (2 levels) in ' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/task.rb:228:incall' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/task.rb:228:in
block in execute' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/task.rb:223:ineach' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/task.rb:223:in
execute' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/task.rb:166:inblock in invoke_with_call_chain' /usr/lib/ruby/1.9.1/monitor.rb:201:in
mon_synchronize' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/task.rb:159:ininvoke_with_call_chain' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/task.rb:152:in
invoke' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/application.rb:143:ininvoke_task' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/application.rb:101:in
block (2 levels) in top_level' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/application.rb:101:ineach' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/application.rb:101:in
block in top_level' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/application.rb:110:inrun_with_threads' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/application.rb:95:in
top_level' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/application.rb:73:inblock in run' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/application.rb:160:in
standard_exception_handling' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/lib/rake/application.rb:70:inrun' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/gems/rake-0.9.6/bin/rake:37:in
' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/bin/rake:23:inload' /var/application/nus/nusdigital/vendor/bundle/ruby/1.9.1/bin/rake:23:in
' ------------------------------- Data: