Fix celery worker initialization by setting up Django before Celery and fixing import name

This commit is contained in:
2026-05-05 13:09:54 +02:00
parent ce5aac0e89
commit 3eb81b343c
3 changed files with 14 additions and 5 deletions
+8
View File
@@ -72,3 +72,11 @@ Only sells to Almería province, Spain (postal codes 04xxx). All addresses saved
- github Defaults to the GITHUB repo
- gitlab Defaults to a Gitlab mirror (doesn't work by now)
# Deploy machine info.
- Every time you make a change, please commit it and push it to "origin and github", and verify github actions succeeded.
- When Github Actions succeed, it will update the docker image "ghcr.io/dsaub/proyecto-mvc:development".
- When "ghcr.io/dsaub/proyecto-mvc:development" updates, that affects swarm mvc_web and mvc_worker services, so update them
- You can SSH docker swarm "Docker 1" instance at debian@172.16.14.221
- Docker SWARM is in my school's OpenStack, needing the VPN, if you can't connect, OMIT the deploy, if you can, then do.
- Docker Swarm Stack is at /home/debian/composes/mvc/mvc.yml. That file is on "debian@172.16.14.221" server.
- WARNING: Updating the Docker SWARM SERVICE can HANG UP indefinitely, apply a 1-minute time out so if it's still executing it stops it by force
+2 -2
View File
@@ -1,2 +1,2 @@
from .celery import app as celery_app
__all__ = ('celery_app',)
from .celery import app as celery
__all__ = ('celery',)
+4 -3
View File
@@ -1,10 +1,11 @@
from celery import Celery
import os
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proyecto.settings')
django.setup()
app = Celery('proyecto')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proyecto.settings')
app.config_from_object('django.conf:settings', namespace="CELERY")
app.user_options = {}
app.autodiscover_tasks()