This commit is contained in:
imperosol
2025-04-28 12:03:51 +02:00
parent f647feb8c8
commit 934d17d9d2
7 changed files with 249 additions and 0 deletions

View File

@ -12,3 +12,9 @@
# OR WITHIN THE LOCAL FILE "LICENSE"
#
#
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
__all__ = ("celery_app",)

17
sith/celery.py Normal file
View File

@ -0,0 +1,17 @@
# Set the default Django settings module for the 'celery' program.
import os
from celery import Celery
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sith.settings")
app = Celery("sith")
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object("django.conf:settings", namespace="CELERY")
# Load task modules from all registered Django apps.
app.autodiscover_tasks()

View File

@ -106,6 +106,8 @@ INSTALLED_APPS = (
"django_jinja",
"ninja_extra",
"haystack",
"django_celery_results",
"django_celery_beat",
"captcha",
"core",
"club",
@ -336,6 +338,14 @@ EMAIL_BACKEND = env.str(
EMAIL_HOST = env.str("EMAIL_HOST", default="localhost")
EMAIL_PORT = env.int("EMAIL_PORT", default=25)
# Celery
CELERY_TIMEZONE = TIME_ZONE
CELERY_TASK_TRACK_STARTED = True
CELERY_TASK_TIME_LIMIT = 30 * 60
CElERY_BROKER_URL = env.str("CELERY_BROKER_URL", default="redis://localhost:6379/1")
CELERY_RESULT_BACKEND = "django-db"
CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"
# Below this line, only Sith-specific variables are defined
SITH_URL = env.str("SITH_URL", default="127.0.0.1:8000")