48 lines
1.2 KiB
Elixir
48 lines
1.2 KiB
Elixir
defmodule Slax.Application do
|
|
@moduledoc false
|
|
|
|
use Application
|
|
|
|
@impl true
|
|
def start(_type, _args) do
|
|
start_testcontainer()
|
|
|
|
children = [
|
|
SlaxWeb.Telemetry,
|
|
Slax.Repo,
|
|
{DNSCluster, query: Application.get_env(:slax, :dns_cluster_query) || :ignore},
|
|
{Phoenix.PubSub, name: Slax.PubSub},
|
|
# Start the Finch HTTP client for sending emails
|
|
{Finch, name: Slax.Finch},
|
|
SlaxWeb.Presence,
|
|
SlaxWeb.Endpoint
|
|
]
|
|
|
|
opts = [strategy: :one_for_one, name: Slax.Supervisor]
|
|
Supervisor.start_link(children, opts)
|
|
end
|
|
|
|
def start_testcontainer do
|
|
if Application.get_env(:testcontainers, :database_enabled, false) do
|
|
opts =
|
|
case Application.get_env(:testcontainers, :database_volume) do
|
|
nil ->
|
|
[app: :slax]
|
|
|
|
database_volume ->
|
|
[app: :slax, persistent_volume_name: "#{database_volume}_data"]
|
|
end
|
|
|
|
{:ok, _database_container} = Testcontainers.Ecto.postgres_container(opts)
|
|
end
|
|
end
|
|
|
|
# Tell Phoenix to update the endpoint configuration
|
|
# whenever the application is updated.
|
|
@impl true
|
|
def config_change(changed, _new, removed) do
|
|
SlaxWeb.Endpoint.config_change(changed, removed)
|
|
:ok
|
|
end
|
|
end
|