mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 01:21:07 +00:00
Add support for specifying redis url to support unix sockets
This commit is contained in:
parent
788a33ee8a
commit
207abed654
6 changed files with 12 additions and 22 deletions
|
@ -32,6 +32,8 @@ REDIS_ACTIVITY_PORT=6379
|
|||
REDIS_ACTIVITY_PASSWORD=redispassword345
|
||||
# Optional, use a different redis database (defaults to 0)
|
||||
# REDIS_ACTIVITY_DB_INDEX=0
|
||||
# Alternatively specify the full redis url, i.e. if you need to use a unix:// socket
|
||||
# REDIS_ACTIVITY_URL=
|
||||
|
||||
# Redis as celery broker
|
||||
REDIS_BROKER_HOST=redis_broker
|
||||
|
@ -39,6 +41,8 @@ REDIS_BROKER_PORT=6379
|
|||
REDIS_BROKER_PASSWORD=redispassword123
|
||||
# Optional, use a different redis database (defaults to 0)
|
||||
# REDIS_BROKER_DB_INDEX=0
|
||||
# Alternatively specify the full redis url, i.e. if you need to use a unix:// socket
|
||||
# REDIS_BROKER_URL=
|
||||
|
||||
# Monitoring for celery
|
||||
FLOWER_PORT=8888
|
||||
|
|
|
@ -4,12 +4,7 @@ import redis
|
|||
|
||||
from bookwyrm import settings
|
||||
|
||||
r = redis.Redis(
|
||||
host=settings.REDIS_ACTIVITY_HOST,
|
||||
port=settings.REDIS_ACTIVITY_PORT,
|
||||
password=settings.REDIS_ACTIVITY_PASSWORD,
|
||||
db=settings.REDIS_ACTIVITY_DB_INDEX,
|
||||
)
|
||||
r = redis.from_url(settings.REDIS_ACTIVITY_URL)
|
||||
|
||||
|
||||
def erase_streams():
|
||||
|
|
|
@ -4,12 +4,7 @@ import redis
|
|||
|
||||
from bookwyrm import settings
|
||||
|
||||
r = redis.Redis(
|
||||
host=settings.REDIS_ACTIVITY_HOST,
|
||||
port=settings.REDIS_ACTIVITY_PORT,
|
||||
password=settings.REDIS_ACTIVITY_PASSWORD,
|
||||
db=settings.REDIS_ACTIVITY_DB_INDEX,
|
||||
)
|
||||
r = redis.from_url(settings.REDIS_ACTIVITY_URL)
|
||||
|
||||
|
||||
class RedisStore(ABC):
|
||||
|
|
|
@ -207,7 +207,7 @@ REDIS_ACTIVITY_HOST = env("REDIS_ACTIVITY_HOST", "localhost")
|
|||
REDIS_ACTIVITY_PORT = env("REDIS_ACTIVITY_PORT", 6379)
|
||||
REDIS_ACTIVITY_PASSWORD = env("REDIS_ACTIVITY_PASSWORD", None)
|
||||
REDIS_ACTIVITY_DB_INDEX = env("REDIS_ACTIVITY_DB_INDEX", 0)
|
||||
|
||||
REDIS_ACTIVITY_URL = env("REDIS_ACTIVITY_URL", f"redis://:{REDIS_ACTIVITY_PASSWORD}@{REDIS_ACTIVITY_HOST}:{REDIS_ACTIVITY_PORT}/{REDIS_ACTIVITY_DB_INDEX}")
|
||||
MAX_STREAM_LENGTH = int(env("MAX_STREAM_LENGTH", 200))
|
||||
|
||||
STREAMS = [
|
||||
|
@ -232,7 +232,7 @@ else:
|
|||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "django_redis.cache.RedisCache",
|
||||
"LOCATION": f"redis://:{REDIS_ACTIVITY_PASSWORD}@{REDIS_ACTIVITY_HOST}:{REDIS_ACTIVITY_PORT}/{REDIS_ACTIVITY_DB_INDEX}",
|
||||
"LOCATION": REDIS_ACTIVITY_URL,
|
||||
"OPTIONS": {
|
||||
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
||||
},
|
||||
|
|
|
@ -8,12 +8,7 @@ import redis
|
|||
from celerywyrm import settings
|
||||
from bookwyrm.tasks import app as celery
|
||||
|
||||
r = redis.Redis(
|
||||
host=settings.REDIS_BROKER_HOST,
|
||||
port=settings.REDIS_BROKER_PORT,
|
||||
password=settings.REDIS_BROKER_PASSWORD,
|
||||
db=settings.REDIS_BROKER_DB_INDEX,
|
||||
)
|
||||
r = redis.from_url(settings.REDIS_BROKER_URL)
|
||||
|
||||
# pylint: disable= no-self-use
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
|
|
|
@ -8,9 +8,10 @@ REDIS_BROKER_PASSWORD = requests.utils.quote(env("REDIS_BROKER_PASSWORD", None))
|
|||
REDIS_BROKER_HOST = env("REDIS_BROKER_HOST", "redis_broker")
|
||||
REDIS_BROKER_PORT = env("REDIS_BROKER_PORT", 6379)
|
||||
REDIS_BROKER_DB_INDEX = env("REDIS_BROKER_DB_INDEX", 0)
|
||||
REDIS_BROKER_URL = env("REDIS_BROKER_URL",f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/{REDIS_BROKER_DB_INDEX}")
|
||||
|
||||
CELERY_BROKER_URL = f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/{REDIS_BROKER_DB_INDEX}"
|
||||
CELERY_RESULT_BACKEND = f"redis://:{REDIS_BROKER_PASSWORD}@{REDIS_BROKER_HOST}:{REDIS_BROKER_PORT}/{REDIS_BROKER_DB_INDEX}"
|
||||
CELERY_BROKER_URL = REDIS_BROKER_URL.replace("unix:","redis+socket:")
|
||||
CELERY_RESULT_BACKEND = REDIS_BROKER_URL.replace("unix:","redis+socket:")
|
||||
|
||||
CELERY_DEFAULT_QUEUE = "low_priority"
|
||||
CELERY_CREATE_MISSING_QUEUES = True
|
||||
|
|
Loading…
Reference in a new issue