diff --git a/lib/towerops/application.ex b/lib/towerops/application.ex index 7e21d308..5170c5c6 100644 --- a/lib/towerops/application.ex +++ b/lib/towerops/application.ex @@ -117,6 +117,14 @@ defmodule Towerops.Application do node_name: node() ] + # Add password if configured + base_opts = + case System.get_env("REDIS_PASSWORD") do + nil -> base_opts + "" -> base_opts + password -> Keyword.put(base_opts, :password, password) + end + # Add resilience options for better reconnection handling resilience_opts = [ # Redix connection options for better resilience diff --git a/lib/towerops/exq_supervisor.ex b/lib/towerops/exq_supervisor.ex index cbf3281c..40f94a57 100644 --- a/lib/towerops/exq_supervisor.ex +++ b/lib/towerops/exq_supervisor.ex @@ -65,7 +65,7 @@ defmodule Towerops.ExqSupervisor do end defp build_exq_config(redis_config) do - [ + base_config = [ name: Exq, host: Keyword.get(redis_config, :host, "localhost"), port: Keyword.get(redis_config, :port, 6379), @@ -96,5 +96,12 @@ defmodule Towerops.ExqSupervisor do socket_opts: [keepalive: true] ] ] + + # Add password if configured + case System.get_env("REDIS_PASSWORD") do + nil -> base_config + "" -> base_config + password -> Keyword.put(base_config, :password, password) + end end end