Current section

Files

Jump to
nerves_bootstrap templates new lib app_name application.ex
Raw

templates/new/lib/app_name/application.ex

defmodule <%= app_module %>.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
children =
[
# Children for all targets
# Starts a worker by calling: <%= app_module %>.Worker.start_link(arg)
# {<%= app_module %>.Worker, arg},
] ++ target_children()
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: <%= app_module %>.Supervisor]
Supervisor.start_link(children, opts)
end
# List all child processes to be supervised
if Mix.target() == :host do
defp target_children() do
[
# Children that only run on the host during development or test.
# In general, prefer using `config/host.exs` for differences.
#
# Starts a worker by calling: Host.Worker.start_link(arg)
# {Host.Worker, arg},
]
end
else
defp target_children() do
[
# Children for all targets except host
# Starts a worker by calling: Target.Worker.start_link(arg)
# {Target.Worker, arg},
]
end
end
end