%Porcelain.UsageError{message: “Looks like the :porcelain app is not running”}

This error happened to be in my logs when I did a hot upgrade for elixir application using distillery. As its clear from error, the Porcelain app was not being started after the hot upgrade. It’s already there in application list as well.

.....other apps

After looking around I found a solution to re-init the Porcelain application after the hot upgrade which was

  def config_change(changed, _new, removed) do
    EvercamMediaWeb.Endpoint.config_change(changed, removed)

  defp ensure_porcelain_init() do
    Task.async(fn ->
      # Wait ten seconds after deploy and then try to reinit porcelain

But even after doing this Porcelain app is not started and I get the error when I start any process which includes Porcelain .

When I do this

iex(4)> Porcelain.Init.init

There is no error but even after that the above error still exists.

I’ve not used hot upgrades so far, but have you tried to use Application.ensure_started/2? From its description it seems to be much more what you actually want.

Okay if application’s dep is not started then this method will start it too? again?

And where to call it? on hot code deploy?

on this place or somewhere else when we do hot code deploy?

According to its documentation, that function should start an application and all of its dependencies.

Where to do this is not clear to me though, as I do not use hot upgrades (or any form of deployment currently).

Okay so anyone else here from 200+ online users, no body is willing to help :smiley:

If Porcelain did not restart after the hot upgrade then that implies to me that it’s supervisor is set to something like transient or temporary or so, what is it set to?

Actually, there is a process already running when I deploy application. that process is running few commands for shell, e.g. ffmpeg. Is that causing any problem?

The Porcelain process should have stopped first to do hot code deploy?

I’d think that process would keep running fine but couldn’t say for sure unless the source is checked…

Are you able to make a minimal reproduceable example with a script to automate testing it? If so then that would be a fantastic thing to debug!

Actually if you have done hot upgrades then can you tell me is there any place in Application which get called when you do upgrade? with distillery? I can reinit the application again but I dont know the place where i Can.

That’s the standard beam-OTP specified code_change callback. :slight_smile:

That message gets sent to a process when it’s code changed via a hot-swap to allow you to migrate state between formats and so forth.

I hope you will see and tell what is the issue now?

Not seeing the issue off-hand, it’s only called when the system sends a message to a system managed process like a GenServer. I’d have to see a SSCCE repo example to say why otherwise. :slight_smile: