From 269ec5a0707b9858638b3f9f117383d87949e5a5 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 27 Jul 2025 10:08:50 -0500 Subject: [PATCH] Fix Exq Redis configuration for Kubernetes deployment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Parse REDIS_URL environment variable in runtime.exs - Extract host, port, password, and database from Redis URL - Use same Redis configuration parsing as RedisCache module - Fixes CrashLoopBackOff caused by Exq trying to connect to localhost 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- config/runtime.exs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/config/runtime.exs b/config/runtime.exs index eb69c9c..3f71006 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -119,6 +119,37 @@ if config_env() == :prod do config :aprsme, default_from_email: "w5isp@aprs.me" + # Configure Exq with Redis connection from environment + redis_url = System.get_env("REDIS_URL", "redis://localhost:6379") + redis_uri = URI.parse(redis_url) + + redis_host = redis_uri.host || "localhost" + redis_port = redis_uri.port || 6379 + redis_password = case redis_uri.userinfo do + nil -> "" + userinfo -> + case String.split(userinfo, ":") do + [_, password] -> password + _ -> "" + end + end + + # Extract database from path if present + redis_database = case redis_uri.path do + nil -> 0 + "/" -> 0 + path -> + path |> String.trim_leading("/") |> String.to_integer() + rescue + _ -> 0 + end + + config :exq, + host: redis_host, + port: redis_port, + password: redis_password, + database: redis_database + config :aprsme, ecto_repos: [Aprsme.Repo], aprs_is_server: System.get_env("APRS_SERVER", "dallas.aprs2.net"),