feat: Add basic celery config

This commit is contained in:
moanos [he/him] 2024-10-09 21:54:31 +02:00
parent ab2b91735e
commit 39893c2185
5 changed files with 34 additions and 4 deletions

View File

@ -106,3 +106,20 @@ Use a program like `gtranslator` or `poedit` to start translations
| Edit adoption notice | User that created, Moderator, Admin |
| Edit animal | User that created, Moderator, Admin |
| Add animal/photo to adoption notice | User that created, Moderator, Admin |
# Celery and KeyDB
Start KeyDB docker container
```zsh
docker run -d --name keydb -p 6379:6379 eqalpha/keydb
```
Start worker
```zsh
celery -A notfellchen.celery worker
```
Start beat
```zsh
celery -A notfellchen.celery beat
```

View File

@ -38,7 +38,8 @@ dependencies = [
"psycopg2-binary",
"django-crispy-forms",
"crispy-bootstrap4",
"djangorestframework"
"djangorestframework",
"celery[redis]"
]
dynamic = ["version", "readme"]

View File

@ -0,0 +1,6 @@
from notfellchen.celery import app as celery_app
from .tools.admin import clean_locations
@celery_app.task(name="admin.clean_locations")
def task_clean_locations():
clean_locations()

View File

@ -14,6 +14,7 @@ from pathlib import Path
import os
import configparser
from django.utils.translation import gettext_lazy as _
from celery import Celery
"""CONFIG PARSER """
config = configparser.RawConfigParser()
@ -79,6 +80,11 @@ DB_HOST = config.get("database", "host", fallback='')
BASE_DIR = Path(__file__).resolve().parent.parent
LOCALE_PATHS = [os.path.join(BASE_DIR, 'locale')]
""" CELERY + KEYDB """
CELERY_BROKER_URL = config.get("celery", "broker", fallback="redis://localhost:6379/0")
CELERY_RESULT_BACKEND = config.get("celery", "backend", fallback="redis://localhost:6379/0")
""" GEOCODING """
GEOCODING_API_URL = config.get("geocoding", "api_url", fallback="https://nominatim.hyteck.de/search")
""" Tile Server """