mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-06-28 09:50:05 +00:00
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
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 13m45s
This commit is contained in:
@ -0,0 +1,4 @@
|
||||
# myproject/__init__.py
|
||||
from .celery import app as celery_app
|
||||
|
||||
__all__ = ("celery_app",)
|
||||
|
22
apibase/celery.py
Normal file
22
apibase/celery.py
Normal 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}")
|
@ -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"
|
||||
|
Reference in New Issue
Block a user