Add debugging and validation for cluster topologies
This commit is contained in:
parent
17f5a162aa
commit
35224327c0
1 changed files with 18 additions and 2 deletions
|
|
@ -2,12 +2,28 @@ defmodule Aprsme.Cluster.Topology do
|
|||
@moduledoc """
|
||||
Wrapper for Cluster.Supervisor that only starts when clustering is enabled.
|
||||
"""
|
||||
require Logger
|
||||
|
||||
def child_spec(opts) do
|
||||
if Application.get_env(:aprsme, :cluster_enabled, false) do
|
||||
topologies = Application.get_env(:libcluster, :topologies, [])
|
||||
supervisor_opts = Keyword.merge([name: Aprsme.ClusterSupervisor], opts)
|
||||
{Cluster.Supervisor, [topologies, supervisor_opts]}
|
||||
|
||||
# Log the configuration for debugging
|
||||
Logger.info("Cluster.Topology starting with topologies: #{inspect(topologies)}")
|
||||
|
||||
# Ensure we have valid topologies
|
||||
if topologies == [] or topologies == nil do
|
||||
Logger.warning("No libcluster topologies configured, clustering will not work")
|
||||
# Return a no-op spec
|
||||
%{
|
||||
id: __MODULE__,
|
||||
start: {__MODULE__, :start_link, [opts]},
|
||||
type: :worker
|
||||
}
|
||||
else
|
||||
supervisor_opts = Keyword.merge([name: Aprsme.ClusterSupervisor], opts)
|
||||
{Cluster.Supervisor, [topologies, supervisor_opts]}
|
||||
end
|
||||
else
|
||||
# Return a no-op spec when clustering is disabled
|
||||
%{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue