All checks were successful
deploy / deploy (push) Successful in 56s
Card radio component for picking email providers (SMTP, SendGrid, Mailjet, etc.) with instant client-side switching via JS hook. Adapter configs are pre-rendered and toggled without a server round-trip. Secrets are preserved when re-saving with blank password fields. Includes from address field, test email sending, and disconnect flow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
68 lines
2.2 KiB
Elixir
68 lines
2.2 KiB
Elixir
defmodule Berrypod.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 = [
|
|
BerrypodWeb.Telemetry,
|
|
Berrypod.Repo,
|
|
{Ecto.Migrator,
|
|
repos: Application.fetch_env!(:berrypod, :ecto_repos), skip: skip_migrations?()},
|
|
# Seed default theme settings if none exist (first boot)
|
|
Supervisor.child_spec({Task, &Berrypod.Release.seed_defaults/0}, id: :seed_defaults),
|
|
# Load encrypted secrets from DB into Application env
|
|
{Task, &Berrypod.Secrets.load_all/0},
|
|
# Load email adapter config from DB (after secrets are available)
|
|
Supervisor.child_spec({Task, &Berrypod.Mailer.load_config/0}, id: :load_email_config),
|
|
{DNSCluster, query: Application.get_env(:berrypod, :dns_cluster_query) || :ignore},
|
|
{Phoenix.PubSub, name: Berrypod.PubSub},
|
|
# Background job processing
|
|
{Oban, Application.fetch_env!(:berrypod, Oban)},
|
|
# Image variant cache - ensures all variants exist on startup
|
|
Berrypod.Images.VariantCache,
|
|
# Start to serve requests
|
|
BerrypodWeb.Endpoint,
|
|
# Theme CSS cache - must start after Endpoint for static_path/1 to work
|
|
Berrypod.Theme.CSSCache
|
|
]
|
|
|
|
# See https://hexdocs.pm/elixir/Supervisor.html
|
|
# for other strategies and supported options
|
|
opts = [strategy: :one_for_one, name: Berrypod.Supervisor]
|
|
result = Supervisor.start_link(children, opts)
|
|
|
|
log_setup_secret_if_needed()
|
|
|
|
result
|
|
end
|
|
|
|
defp log_setup_secret_if_needed do
|
|
if Application.get_env(:berrypod, :env) != :test do
|
|
unless Berrypod.Accounts.has_admin?() do
|
|
secret = Berrypod.Setup.setup_secret()
|
|
|
|
require Logger
|
|
|
|
Logger.info("Setup secret: #{secret} — visit /setup to create your admin account")
|
|
end
|
|
end
|
|
end
|
|
|
|
# Tell Phoenix to update the endpoint configuration
|
|
# whenever the application is updated.
|
|
@impl true
|
|
def config_change(changed, _new, removed) do
|
|
BerrypodWeb.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
|