From 37dcae4558ac3ae66bb5019c2869890fd72b5954 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 7 Sep 2021 13:51:59 -0700 Subject: [PATCH] Simply celery settings --- bookwyrm/settings.py | 11 ----------- bookwyrm/tasks.py | 4 ++-- celerywyrm/settings.py | 11 ++++++++++- redis.conf | 9 +++++++++ 4 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 redis.conf diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index c1f900794..9450ba81f 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -13,17 +13,6 @@ VERSION = "0.0.1" PAGE_LENGTH = env("PAGE_LENGTH", 15) DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English") -# celery -CELERY_BROKER = "redis://:{}@redis_broker:{}/0".format( - requests.utils.quote(env("REDIS_BROKER_PASSWORD", "")), env("REDIS_BROKER_PORT") -) -CELERY_RESULT_BACKEND = "redis://:{}@redis_broker:{}/0".format( - requests.utils.quote(env("REDIS_BROKER_PASSWORD", "")), env("REDIS_BROKER_PORT") -) -CELERY_ACCEPT_CONTENT = ["application/json"] -CELERY_TASK_SERIALIZER = "json" -CELERY_RESULT_SERIALIZER = "json" - # email EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend") EMAIL_HOST = env("EMAIL_HOST") diff --git a/bookwyrm/tasks.py b/bookwyrm/tasks.py index 6d1992a77..b860e0184 100644 --- a/bookwyrm/tasks.py +++ b/bookwyrm/tasks.py @@ -2,10 +2,10 @@ import os from celery import Celery -from bookwyrm import settings +from celerywyrm import settings # set the default Django settings module for the 'celery' program. os.environ.setdefault("DJANGO_SETTINGS_MODULE", "celerywyrm.settings") app = Celery( - "tasks", broker=settings.CELERY_BROKER, backend=settings.CELERY_RESULT_BACKEND + "tasks", broker=settings.CELERY_BROKER_URL, backend=settings.CELERY_RESULT_BACKEND ) diff --git a/celerywyrm/settings.py b/celerywyrm/settings.py index 107a39572..a67ab4113 100644 --- a/celerywyrm/settings.py +++ b/celerywyrm/settings.py @@ -1,9 +1,18 @@ """ bookwyrm settings and configuration """ +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import from bookwyrm.settings import * -CELERY_BROKER_URL = CELERY_BROKER +CELERY_BROKER_URL = "redis://:{}@redis_broker:{}/0".format( + requests.utils.quote(env("REDIS_BROKER_PASSWORD", "")), env("REDIS_BROKER_PORT") +) +CELERY_RESULT_BACKEND = "redis://:{}@redis_broker:{}/0".format( + requests.utils.quote(env("REDIS_BROKER_PASSWORD", "")), env("REDIS_BROKER_PORT") +) + CELERY_ACCEPT_CONTENT = ["json"] CELERY_TASK_SERIALIZER = "json" +CELERY_RESULT_SERIALIZER = "json" FLOWER_PORT = env("FLOWER_PORT") INSTALLED_APPS = INSTALLED_APPS + [ diff --git a/redis.conf b/redis.conf new file mode 100644 index 000000000..2a417579f --- /dev/null +++ b/redis.conf @@ -0,0 +1,9 @@ +bind 127.0.0.1 ::1 +protected-mode yes +port 6379 + +rename-command FLUSHDB "" +rename-command FLUSHALL "" +rename-command DEBUG "" +rename-command CONFIG "" +rename-command SHUTDOWN ""