This document provides instructions for setting up and managing asynchronous tasks in the PinguCrew backend.
Asynchronous tasks are used to handle background operations such as data processing, analytics, and periodic updates. The system uses Celery as the task queue and django-celery-beat for periodic task scheduling.
Ensure the following are set up before configuring tasks:
- RabbitMQ: Used as the message broker.
- TimescaleDB: Used for storing analytics data.
- Minio: Used for storing coverage files.
The "Fuzzing Stats collector" task processes coverage files dropped into Minio buckets and inserts the data into the TimescaleDB analytics database.
-
Add the Task to Periodic Tasks
Use the Django admin interface to schedule the task:
- Navigate to Periodic Tasks > Add Periodic Task.
- Fill in the details:
- Name: Fuzzing Stats collector
- Task (registered):
download_and_update_stats - Interval Schedule: Set to
every houror as needed.
- Save the task.
-
Verify the Task
Start the Celery worker and beat scheduler using the provided
celery_runner.shscript:bash celery_runner.sh
This script will:
- Start the Celery worker to process tasks.
- Start the Celery beat scheduler to manage periodic tasks.
You can monitor task execution using the RabbitMQ management interface or in the Django Admin panel.
- Ensure that the Celery worker and beat scheduler are running for tasks to execute.
- Use secure credentials for RabbitMQ and TimescaleDB in production environments.
- Periodically review and optimize task schedules to avoid overloading the system.
