From 35224327c0d74132f0f6af94417cbda5788596d7 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 25 Jul 2025 10:59:37 -0500 Subject: [PATCH] Add debugging and validation for cluster topologies --- lib/aprsme/cluster/topology.ex | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/aprsme/cluster/topology.ex b/lib/aprsme/cluster/topology.ex index 5d43d0d..16b6703 100644 --- a/lib/aprsme/cluster/topology.ex +++ b/lib/aprsme/cluster/topology.ex @@ -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 %{