Enhance environment variable handling, add Celery configuration, and implement device expiration notification tasks
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 13m45s

This commit is contained in:
2025-04-24 10:42:22 +05:00
parent ee8145f07f
commit 99982d13d5
8 changed files with 106 additions and 14 deletions

View File

@ -0,0 +1,4 @@
# myproject/__init__.py
from .celery import app as celery_app
__all__ = ("celery_app",)

22
apibase/celery.py Normal file
View File

@ -0,0 +1,22 @@
import os
from celery import Celery
# Set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "apibase.settings")
app = Celery("apibase")
# 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(["api", "devices"])
@app.task(bind=True, ignore_result=True)
def debug_task(self):
print(f"Request: {self.request!r}")

View File

@ -363,3 +363,10 @@ PASSWORDLESS_AUTH = {
"PASSWORDLESS_REGISTER_NEW_USERS": True,
"PASSWORDLESS_EMAIL_NOREPLY_ADDRESS": "noreply@sarlink.net",
}
# CELERY CONFIGURATION
CELERY_BROKER_URL = "redis://localhost:6379/0" # or your Redis URL
CELERY_ACCEPT_CONTENT = ["json"]
CELERY_TASK_SERIALIZER = "json"
CELERY_RESULT_BACKEND = "redis://localhost:6379/0"