ammend redis conn check to acccount for sentinel

This commit is contained in:
Dan Starner 2020-02-14 09:39:01 -05:00
parent 0a8d39cfe4
commit 03a7f6bbda

View File

@ -13,6 +13,16 @@ class ExtrasConfig(AppConfig):
# Check that we can connect to the configured Redis database. # Check that we can connect to the configured Redis database.
try: try:
if settings.WEBHOOKS_REDIS_USING_SENTINEL:
sentinel = redis.sentinel.Sentinel(
settings.WEBHOOKS_REDIS_SENTINELS,
socket_timeout=settings.WEBHOOKS_REDIS_DEFAULT_TIMEOUT
)
rs = sentinel.master_for(
settings.WEBHOOKS_REDIS_SENTINEL_SERVICE,
socket_timeout=settings.WEBHOOKS_REDIS_DEFAULT_TIMEOUT
)
else:
rs = redis.Redis( rs = redis.Redis(
host=settings.WEBHOOKS_REDIS_HOST, host=settings.WEBHOOKS_REDIS_HOST,
port=settings.WEBHOOKS_REDIS_PORT, port=settings.WEBHOOKS_REDIS_PORT,