feat: add Redis password authentication support
Add REDIS_PASSWORD environment variable support to both Phoenix.PubSub.Redis and Exq background job processor. Password is optional - if not set, connects without authentication. Changes: - application.ex: Add password to PubSub Redis config if REDIS_PASSWORD is set - exq_supervisor.ex: Add password to Exq Redis config if REDIS_PASSWORD is set Required for connecting to Proxmox-hosted Redis with authentication.
This commit is contained in:
parent
be818b49b8
commit
0d4c8eb15a
2 changed files with 16 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue