Browse Source

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

pull/12589/head
feng 10 months ago committed by Bryan
parent
commit
6c9d271ae1
  1. 17
      utils/start_celery_beat.py

17
utils/start_celery_beat.py

@ -1,13 +1,12 @@
#!/usr/bin/env python
#
import os
import sys
import signal
import subprocess
import sys
import redis_lock
from redis import Redis, Sentinel
from redis import Redis, Sentinel, ConnectionPool
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
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)
else:
connection_params['host'] = settings.REDIS_HOST
connection_params['port'] = settings.REDIS_PORT
redis_client = Redis(**connection_params)
REDIS_PROTOCOL = 'rediss' if settings.REDIS_USE_SSL else 'redis'
REDIS_LOCATION_NO_DB = '%(protocol)s://:%(password)s@%(host)s:%(port)s' % {
'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"
processes = []

Loading…
Cancel
Save