Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot code upgrades do not start porcelain #41

Open
NilsLattek opened this issue Jun 25, 2017 · 4 comments
Open

Hot code upgrades do not start porcelain #41

NilsLattek opened this issue Jun 25, 2017 · 4 comments

Comments

@NilsLattek
Copy link

I am using https://github.com/gutschilla/elixir-pdf-generator which depends on porcelain.
Elixir: 1.4
Erlang: 19
Porcelain: 2.0.3

Everything works fine, but when I do a hot code upgrade using releases with distillery, I can get error when call the pdf/porcelain code after the upgrade:

Ranch listener MyApp.Endpoint.HTTP had connection process started with :cowboy_protocol:start_link/4 at #PID<0.24063.0> exit with reason: 
{{%Porcelain.UsageError{message: "Looks like the :porcelain app is not running. Make sure you've added :porcelain to the list of applications in your mix.exs."}, 
[{Porcelain, :driver, 0, [file: 'lib/porcelain.ex', line: 419]}, 
 {Porcelain, :"-exec/3-fun-0-", 3, [file: 'lib/porcelain.ex', line: 131]}, 
 {Porcelain, :catch_throws, 1, [file: 'lib/porcelain.ex', line: 273]}, 
 {PdfGenerator, :generate, 2, [file: 'lib/pdf_generator.ex', line: 136]}, 
 {PdfGenerator, :generate_binary, 2, [file: 'lib/pdf_generator.ex', line: 188]}, 
 ...
]}, 
{MyApp.Endpoint, :call, [
  %Plug.Conn{ ... }}

When I restart my application/release it works again. So this currently prevents me from using hot code upgrades. Everything else works after the upgrade.
Porcelain is added in the mix.exs file:

def application do
    [mod: {MyApp, []},
     extra_applications: [
       :logger,
       :runtime_tools,
       :misc_random,
       :porcelain
      ]
    ]
  end

I also tried to add it to the distillery release config, without a difference.
Any ideas? Is it better to post this on pdf_generator or distillery issue tracker?

@Preen
Copy link

Preen commented Sep 6, 2017

Any news on this?!

@samginn
Copy link

samginn commented Nov 7, 2017

I'm experiencing the same error. Any updates on workarounds?

@darksheik
Copy link

It looks like the Supervisor does survive the hot upgrade, but it is not calling:

Porcelain.Init.init()

Doing this sets:

Application.fetch_env(:porcelain, :driver_internal)

If this environment variable is not set, you will see the error message that the app is not running.

@darksheik
Copy link

I made a little workaround for this which waits a bit after a config change before trying to reinit Porcelain. There may be a more elegant way to do this.

  defp ensure_porcelain_init() do
    Task.async(fn ->
      # Wait ten seconds after deploy and then try to reinit porcelain
      :timer.sleep(10000)
      Porcelain.Init.init()
    end)
  end

  # Tell Phoenix to update the endpoint configuration
  # whenever the application is updated.
  def config_change(changed, _new, removed) do
    ...
    ensure_porcelain_init()
    :ok
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants