Check if celery bandage is working

In my Django project, I use Celery and Rabbitmq to run tasks in the background. I use the billiards planner to perform periodic tasks. How can I check if the celery cycle works programmatically?

+7
django celery celerybeat
source share
4 answers

You can check whether the scheduler starts or not with the following command

python manage.py celery worker --beat 
0
source share

Are you using upstart or surveillance or something else to work with celery + celery beating as background tasks? In production, you must use one of them in order to run celery workers + celery bikini in the background.

The easiest way to check how celery shoot works: ps aux | grep -i '[c]elerybeat' ps aux | grep -i '[c]elerybeat' . If you get a text string with pid , it works. You can also make the output of this command prettier: ps aux | grep -i '[c]elerybeat' | awk '{print $2}' ps aux | grep -i '[c]elerybeat' | awk '{print $2}' ps aux | grep -i '[c]elerybeat' | awk '{print $2}' . If you get a number, it works; if you don't get anything, it doesn't work.

You can also check the status of celery workers: celery -A projectname status .

If you are interested in advanced celery monitoring, you can read the official monitoring documentation.

0
source share

If you have demonological celery following the celery doc training site, check to see if it is being performed or not with

 sudo /etc/init.d/celeryd status sudo /etc/init.d/celerybeat status 

You can use returning such commands to the python module.

0
source share

Perhaps you can find a supervisor . It provides a celerybeat conf , which records everything related to the beating in /var/log/celery/beat.log .

Another way to do this is to use Flower . You can configure it for your server (make sure that its password is protected), it is somewhat easier to notice the tasks that are in the queue in the graphical interface and what time they are queued, thus checking if your bit works.

0
source share

All Articles