Can't see my Celery tasks running after deployement

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:

# Start command
daphne -b 0.0.0.0 myproject.asgi:application
# Build command
pip install -r requirements.txt && python manage.py makemigrations && python manage.py migrate

The build and the start commands I used for the Celery background worker:

# Start command
celery -A myproject.celery worker --loglevel=info --concurrency=4 -O fair &
celery -A myproject.celery beat --loglevel=info --scheduler django_celery_beat.schedulers:DatabaseScheduler &

# Build command
pip install -r requirements.txt

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?

Your help is much appreciated!

Hi Rochdi,

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?

Regards,

Matt

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'

I see you asked the same question in another thread

I’ll close this one out.