fix(server): only mark hosts offline when endpoint is serving

Application.start ran mark_all_offline unconditionally, which meant
every "mix run"/"mix ecto.migrate" invocation would flip all
connected hosts to offline. Gate the call on Phoenix.Endpoint.server?
so non-serving boots don't disturb live state.
This commit is contained in:
Carsten 2026-04-21 22:15:35 +02:00
parent 4f82701956
commit 116f1ada14

View file

@ -25,7 +25,11 @@ defmodule Server.Application do
# for other strategies and supported options # for other strategies and supported options
opts = [strategy: :one_for_one, name: Server.Supervisor] opts = [strategy: :one_for_one, name: Server.Supervisor]
result = Supervisor.start_link(children, opts) result = Supervisor.start_link(children, opts)
if Phoenix.Endpoint.server?(:server, ServerWeb.Endpoint) do
with {:ok, _} <- result, do: Server.Hosts.mark_all_offline() with {:ok, _} <- result, do: Server.Hosts.mark_all_offline()
end
result result
end end