|
|
|
@ -4,9 +4,9 @@ import os
|
|
|
|
|
import ssl
|
|
|
|
|
|
|
|
|
|
from .base import (
|
|
|
|
|
REDIS_SSL_CA, REDIS_SSL_CERT, REDIS_SSL_KEY,
|
|
|
|
|
REDIS_SSL_REQUIRED, REDIS_USE_SSL,
|
|
|
|
|
REDIS_SENTINEL_SERVICE_NAME, REDIS_SENTINELS,
|
|
|
|
|
REDIS_SSL_CA, REDIS_SSL_CERT, REDIS_SSL_KEY, REDIS_SSL_REQUIRED, REDIS_USE_SSL,
|
|
|
|
|
REDIS_SENTINEL_SERVICE_NAME, REDIS_SENTINELS, REDIS_SENTINEL_PASSWORD,
|
|
|
|
|
REDIS_SENTINEL_SOCKET_TIMEOUT
|
|
|
|
|
)
|
|
|
|
|
from ..const import CONFIG, PROJECT_DIR
|
|
|
|
|
|
|
|
|
@ -100,6 +100,10 @@ REDIS_HOST = {
|
|
|
|
|
if REDIS_SENTINEL_SERVICE_NAME and REDIS_SENTINELS:
|
|
|
|
|
REDIS_HOST['sentinels'] = REDIS_SENTINELS
|
|
|
|
|
REDIS_HOST['master_name'] = REDIS_SENTINEL_SERVICE_NAME
|
|
|
|
|
REDIS_HOST['sentinel_kwargs'] = {
|
|
|
|
|
'password': REDIS_SENTINEL_PASSWORD,
|
|
|
|
|
'socket_timeout': REDIS_SENTINEL_SOCKET_TIMEOUT
|
|
|
|
|
}
|
|
|
|
|
else:
|
|
|
|
|
REDIS_HOST['address'] = (CONFIG.REDIS_HOST, CONFIG.REDIS_PORT)
|
|
|
|
|
|
|
|
|
@ -124,8 +128,14 @@ if REDIS_SENTINEL_SERVICE_NAME and REDIS_SENTINELS:
|
|
|
|
|
'protocol': 'sentinel', 'password': CONFIG.REDIS_PASSWORD,
|
|
|
|
|
'host': item[0], 'port': item[1], 'db': CONFIG.REDIS_DB_CELERY
|
|
|
|
|
} for item in REDIS_SENTINELS])
|
|
|
|
|
CELERY_BROKER_TRANSPORT_OPTIONS = {"master_name": REDIS_SENTINEL_SERVICE_NAME}
|
|
|
|
|
CELERY_RESULT_BACKEND_TRANSPORT_OPTIONS = {"master_name": REDIS_SENTINEL_SERVICE_NAME}
|
|
|
|
|
SENTINEL_OPTIONS = {
|
|
|
|
|
'master_name': REDIS_SENTINEL_SERVICE_NAME,
|
|
|
|
|
'sentinel_kwargs': {
|
|
|
|
|
'password': REDIS_SENTINEL_PASSWORD,
|
|
|
|
|
'socket_timeout': REDIS_SENTINEL_SOCKET_TIMEOUT
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CELERY_BROKER_TRANSPORT_OPTIONS = CELERY_RESULT_BACKEND_TRANSPORT_OPTIONS = SENTINEL_OPTIONS
|
|
|
|
|
else:
|
|
|
|
|
CELERY_BROKER_URL = CELERY_BROKER_URL_FORMAT % {
|
|
|
|
|
'protocol': 'rediss' if REDIS_USE_SSL else 'redis',
|
|
|
|
|