I set up a Redis server, and Celery background worker to process tasks with a Django web service. All services have been deployed successfully, but nothing is displayed when I checked the home page to see if my tasks and the queue run as expected. I could see the tasks displayed until I go to the shell of the Django web service and run Celery and Celery-beat commands.
The build and start commands I used for the web service:
I don’t know if I miss something, but my question is how can I get my tasks run immediately without doing it manually from the shell of the web service to see them displayed on the home page?
This sounds like it may be more of a Celery question than a Render question. Are you able to run this locally with different results than when it’s running on Render? If it does work locally but not on Render, could you let me know the service id and I’ll take a quick look?
Thank you @mmaddex, and sorry for the delay. I changed the start command of the background worker from the one I mentioned above to the following to run Celery and Beat:
celery -A myproject.celery worker --beat --scheduler django --loglevel=info --concurrency 4
Then, I could get the tasks running. However, some of my tasks run multiple times in my web page while locally not.
Here are my Django and Celery settings:
CELERY_BROKER_URL = "redis://localhost:6379/0" # localhost replaced with Redis internal URL in production
CELERY_RESULT_BACKEND = "redis://localhost:6379/1" # localhost replaced with Redis internal URL in production
TIME_ZONE = 'UTC'
CELERY_ENABLE_UTC = True
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_TIMEZONE = 'UTC'
ASGI_APPLICATION = 'myproject.asgi.application'