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
defmodule MyApp.Application do # See https://hexdocs.pm/elixir/Application.html # 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 https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(children, opts) end end
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
Currently, I do it like this
iex(firstname.lastname@example.org)3> Application.stop(:my_app) :ok iex(email@example.com)4> Application.start(:my_app) :ok