2025-12-30 12:26:26 +00:00
|
|
|
defmodule SimpleshopTheme.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 = [
|
|
|
|
|
SimpleshopThemeWeb.Telemetry,
|
|
|
|
|
SimpleshopTheme.Repo,
|
|
|
|
|
{Ecto.Migrator,
|
|
|
|
|
repos: Application.fetch_env!(:simpleshop_theme, :ecto_repos), skip: skip_migrations?()},
|
2026-02-08 23:42:56 +00:00
|
|
|
# Seed default theme settings if none exist (first boot)
|
|
|
|
|
Supervisor.child_spec({Task, &SimpleshopTheme.Release.seed_defaults/0}, id: :seed_defaults),
|
2026-02-07 17:12:53 +00:00
|
|
|
# Load encrypted secrets from DB into Application env
|
|
|
|
|
{Task, &SimpleshopTheme.Secrets.load_all/0},
|
2025-12-30 12:26:26 +00:00
|
|
|
{DNSCluster, query: Application.get_env(:simpleshop_theme, :dns_cluster_query) || :ignore},
|
|
|
|
|
{Phoenix.PubSub, name: SimpleshopTheme.PubSub},
|
2026-01-25 00:33:09 +00:00
|
|
|
# Background job processing
|
|
|
|
|
{Oban, Application.fetch_env!(:simpleshop_theme, Oban)},
|
|
|
|
|
# Image variant cache - ensures all variants exist on startup
|
|
|
|
|
SimpleshopTheme.Images.VariantCache,
|
2026-01-25 09:32:06 +00:00
|
|
|
# Start to serve requests
|
|
|
|
|
SimpleshopThemeWeb.Endpoint,
|
|
|
|
|
# Theme CSS cache - must start after Endpoint for static_path/1 to work
|
|
|
|
|
SimpleshopTheme.Theme.CSSCache
|
2025-12-30 12:26:26 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# See https://hexdocs.pm/elixir/Supervisor.html
|
|
|
|
|
# for other strategies and supported options
|
|
|
|
|
opts = [strategy: :one_for_one, name: SimpleshopTheme.Supervisor]
|
|
|
|
|
Supervisor.start_link(children, opts)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Tell Phoenix to update the endpoint configuration
|
|
|
|
|
# whenever the application is updated.
|
|
|
|
|
@impl true
|
|
|
|
|
def config_change(changed, _new, removed) do
|
|
|
|
|
SimpleshopThemeWeb.Endpoint.config_change(changed, removed)
|
|
|
|
|
:ok
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
defp skip_migrations?() do
|
|
|
|
|
# By default, sqlite migrations are run when using a release
|
|
|
|
|
System.get_env("RELEASE_NAME") == nil
|
|
|
|
|
end
|
|
|
|
|
end
|