fix: redis 密码有特殊字符celery beat启动失败

pull/12589/head
feng 11 months ago committed by Bryan
parent 6ff852e225
commit 6c9d271ae1

@ -1,13 +1,12 @@
#!/usr/bin/env python #!/usr/bin/env python
# #
import os import os
import sys
import signal import signal
import subprocess import subprocess
import sys
import redis_lock import redis_lock
from redis import Redis, Sentinel, ConnectionPool
from redis import Redis, Sentinel
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
APPS_DIR = os.path.join(BASE_DIR, 'apps') APPS_DIR = os.path.join(BASE_DIR, 'apps')
@ -50,9 +49,15 @@ if REDIS_SENTINEL_SERVICE_NAME and REDIS_SENTINELS:
) )
redis_client = sentinel_client.master_for(REDIS_SENTINEL_SERVICE_NAME) redis_client = sentinel_client.master_for(REDIS_SENTINEL_SERVICE_NAME)
else: else:
connection_params['host'] = settings.REDIS_HOST REDIS_PROTOCOL = 'rediss' if settings.REDIS_USE_SSL else 'redis'
connection_params['port'] = settings.REDIS_PORT REDIS_LOCATION_NO_DB = '%(protocol)s://:%(password)s@%(host)s:%(port)s' % {
redis_client = Redis(**connection_params) 'protocol': REDIS_PROTOCOL,
'password': settings.REDIS_PASSWORD,
'host': settings.REDIS_HOST,
'port': settings.REDIS_PORT,
}
pool = ConnectionPool.from_url(REDIS_LOCATION_NO_DB, **connection_params)
redis_client = Redis(connection_pool=pool)
scheduler = "ops.celery.beat.schedulers:DatabaseScheduler" scheduler = "ops.celery.beat.schedulers:DatabaseScheduler"
processes = [] processes = []

Loading…
Cancel
Save