Current section
Files
Jump to
Current section
Files
templates/needle_single/lib/ctx_lib/supervisor.ex
defmodule <%= inspect @ctx_module %>.Supervisor do
@moduledoc false
use Supervisor
def start_link(arg) do
Supervisor.start_link(__MODULE__, arg, name: __MODULE__)
end
@impl true
def init(_arg) do
children = [
<%= inspect @ctx_module %>.Telemetry<%= if @ecto? do %>,
<%= inspect @ctx_module %>.Repo,<% end %><%= if @ecto_adapter_app == :ecto_sqlite3 do %>
{Ecto.Migrator,
repos: Application.fetch_env!(<%= inspect @ctx_app %>, :ecto_repos),
skip: skip_migrations?()},<% end %>
{DNSCluster, query: Application.get_env(<%= inspect @ctx_app %>, :dns_cluster_query) || :ignore},
{Phoenix.PubSub, name: <%= inspect @ctx_module %>.PubSub}<%= if @mailer? do %>,
# Start the Finch HTTP client for sending emails
{Finch, name: <%= inspect @ctx_module %>.Finch}<% end %>
]
Supervisor.init(children, strategy: :one_for_one)
end<%= if @ecto_adapter_app == :ecto_sqlite3 do %>
defp skip_migrations?() do
# By default, sqlite migrations are run when using a release
System.get_env("RELEASE_NAME") != nil
end<% end %>
end