Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/deployment/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,27 @@ Keep is highly configurable through environment variables. This allows you to cu

| Env var | Purpose | Required | Default Value | Valid options |
| :----------------: | :-------------------: | :------: | :-----------: | :--------------------------: |
| **REDIS** | Redis enabled | No | false | true or false |
| **REDIS_HOST** | Redis server hostname | No | "localhost" | Valid hostname or IP address |
| **REDIS_PORT** | Redis server port | No | 6379 | Valid port number |
| **REDIS_USERNAME** | Redis username | No | None | Valid username string |
| **REDIS_PASSWORD** | Redis password | No | None | Valid password string |

#### Redis Sentinel
<Info>
Redis sentinel configuration specifies the connection details for Keep's Redis sentinel
instance. Redis sentinel is used when you have a redis cluster and it acts as a broker.
</Info>

| Env var | Purpose | Required | Default Value | Valid options |
| :---------------------------------: | :----------------------: | :------: | :-----------------: | :-----------------------------------------: |
| **REDIS** | Redis enabled | No | false | true or false |
| **REDIS_SENTINEL_HOSTS** | Redis sentinel server(s) | No | "localhost:26379" | "host1:port1,host2:port2" (comma-separated) |
| **REDIS_SENTINEL_SERVICE_NAME** | Redis sentinel service name | No | "mymaster" | Valid service name string |
| **REDIS_USERNAME** | Redis username | No | None | Valid username string |
| **REDIS_PASSWORD** | Redis password | No | None | Valid password string |


### ARQ

<Info>
Expand Down
15 changes: 8 additions & 7 deletions keep/api/redis_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
def get_redis_settings() -> RedisSettings:
"""
Get Redis configuration, supporting both direct Redis and Redis Sentinel.

For Redis Sentinel, set:
- REDIS=true
- REDIS_SENTINEL_ENABLED=true
- REDIS_SENTINEL_HOSTS=host1:port1,host2:port2 (comma-separated)
- REDIS_SENTINEL_SERVICE_NAME=mymaster (default: mymaster)

For direct Redis (default):
- REDIS_HOST=localhost (default: localhost)
- REDIS_PORT=6379 (default: 6379)

Returns:
RedisSettings: Configured Redis settings for ARQ
"""
sentinel_enabled = config("REDIS_SENTINEL_ENABLED", cast=bool, default=False)

if sentinel_enabled:
# Parse sentinel hosts from comma-separated string
sentinel_hosts_str = config("REDIS_SENTINEL_HOSTS", default="localhost:26379")
Expand All @@ -38,9 +39,9 @@ def get_redis_settings() -> RedisSettings:
sentinel_hosts.append((host.strip(), int(port.strip())))
else:
sentinel_hosts.append((host_port, 26379))

service_name = config("REDIS_SENTINEL_SERVICE_NAME", default="mymaster")

return RedisSettings(
host=sentinel_hosts,
sentinel=True,
Expand All @@ -60,4 +61,4 @@ def get_redis_settings() -> RedisSettings:
conn_timeout=60,
conn_retries=10,
conn_retry_delay=10,
)
)
Loading