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:
parent
4f82701956
commit
116f1ada14
1 changed files with 5 additions and 1 deletions
|
|
@ -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)
|
||||||
with {:ok, _} <- result, do: Server.Hosts.mark_all_offline()
|
|
||||||
|
if Phoenix.Endpoint.server?(:server, ServerWeb.Endpoint) do
|
||||||
|
with {:ok, _} <- result, do: Server.Hosts.mark_all_offline()
|
||||||
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue