gutschilla / elixir-pdf-generator

Create PDFs with wkhtmltopdf or puppeteer/chromium from Elixir.
MIT License
332 stars 71 forks source link

Application pdf_generator exited: PdfGenerator.start(:normal, []) returned an error: shutdown: failed to start child: PdfGenerator.PathAgent #69

Open ruben44bac opened 4 years ago

ruben44bac commented 4 years ago

Hi. I have this problem when deploy my elixir project with docker, when I'm working in localhost I don't have problems, I'm using wkhtmltopdf and {:pdf_generator, ">=0.5.7"} this is the error

22:47:37.725 [info] [alarm_handler: {:set, {:system_memory_high_watermark, []}}]
22:47:37.730 [info] Application pdf_generator exited: PdfGenerator.start(:normal, []) returned an error: shutdown: failed to start child: PdfGenerator.PathAgent
    ** (EXIT) an exception was raised:
        ** (RuntimeError) wkhtmltopdf executable was not found on your system
            (pdf_generator) lib/pdf_generator_path_agent.ex:76: PdfGenerator.PathAgent.maybe_raise/3
            (pdf_generator) lib/pdf_generator_path_agent.ex:69: PdfGenerator.PathAgent.raise_or_continue/1
            (pdf_generator) lib/pdf_generator_path_agent.ex:37: PdfGenerator.PathAgent.init_opts/1
            (elixir) lib/agent/server.ex:8: Agent.Server.init/1
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
22:47:37.731 [info] [alarm_handler: {:clear, :system_memory_high_watermark}]

this is my dockerfile:

FROM elixir:1.9.1 as builder

ENV MIX_ENV=prod

RUN apt install curl \
  && curl -sL https://deb.nodesource.com/setup_12.x | bash - \
  && apt-get install -y nodejs \
  && apt-get install -y npm

RUN apt-get update && \
    apt-get install -y --no-install-recommends wkhtmltopdf && \
    rm -rf /var/lib/apt/lists/*

RUN mix local.hex --force \
  && mix local.rebar --force
...

help!

gutschilla commented 4 years ago

Hi @ruben44bac ,

First of all, thanks for reporting! Looks like the executable cannot be found on path. You can either configure that path manually (see README) or ... lemme try to reproduce the error.

But before I can take a deeper look into this, I would really recommend to set the path to the wkhtmltopdf executable in the config. This should work. Please let me know if you run into further issues

ruben44bac commented 4 years ago

Thank you! Now I only have this problem, do you know why?

{:error,
 {:generator_failed,
  "/usr/local/bin/wkhtmltopdf: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory\n"}}