Reputation: 1872
I have a Celery+Redis python application.
I have to find number of tasks in queue. I trying this command, but the output is zero. I am confident that queue is not empty.
redis-cli -n 1 -h localhost -p 6379 llen celery
(integer) 0
I think I am using invalid arguments. My redis + celery configuration:
celery:
build: ./project
command: celery -A core_app worker --loglevel=info --concurrency=15 --max-memory-per-child=1000000
volumes:
- ./project:/usr/src/app
- ./project/media:/project/media
- ./project/logs:/project/logs
env_file:
- .env
environment:
# environment variables declared in the environment section override env_file
- DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
depends_on:
- django
- redis
redis:
build:
context: ./redis_customization
dockerfile: Dockerfile
image: redis:7.2-alpine
restart: always
ports:
- 6379:6379
# Run the init script
command: sh -c "./init.sh"
# Run as privileged to allow the container to change the vm.overcommit_memory setting
privileged: true
Upvotes: 0
Views: 67
Reputation: 4332
Your config file shows that the Celery broker and backend are both using database 0, which is the default. That what the /0
at the end of these Redis URLs means:
- CELERY_BROKER=redis://redis:6379/0
- CELERY_BACKEND=redis://redis:6379/0
The port
and hostname
default to 6379
and localhost
as well.
So, you should be able to just do:
redis-cli llen celery
This is assuming that you are not using any customized prefixes and are using the default queue. I don't see any of the former in your yaml
file but if you are using a custom queue, it'll be something like
redis-cli llen celery.my-custom-queue
Hope this helps!
Upvotes: 2
Reputation: 1
You used the -n 1
parameter, which indicates using database number 1. Redis has 16 databases by default, numbered from 0 to 15. If you want to use the first database, it might be -n 0
instead of -n 1
. Please check if your data is stored in database number 1.
Upvotes: 0