Starting a child in a hot upgrade

Is it possible to start a child that was added to a list of supervised children after the initial release was built and the running application was started?

Say, the release was built with the following application.ex:

defmodule MyApp.Application do
  # See
  # for more information on OTP Applications
  @moduledoc false

  use Application

  def start(_type, _args) do
    # List all child processes to be supervised
    children = [
      # MyApp.Worker

    # See
    # for other strategies and supported options
    opts = [strategy: :one_for_one, name: MyApp.Supervisor]
    Supervisor.start_link(children, opts)

and then an upgrade was built with MyApp.Worker uncommented. In my case, after I make a hot upgrade, the uncommented MyApp.Worker is not started. What’s the easiest way to start it? Restart MyApp somehow?

Currently, I do it like this

iex(my_umbrella@> Application.stop(:my_app)
iex(my_umbrella@> Application.start(:my_app)
1 Like

You can specify to start the child (or restart the whole application) in your appup file.