# Script to start Celery components | |
# Check if we're in the right directory | |
if [ ! -f "app.py" ]; then | |
echo "Please run this script from the backend directory" | |
exit 1 | |
fi | |
# Function to start Celery worker | |
start_worker() { | |
echo "Starting Celery worker..." | |
python start_celery.py worker & | |
echo "Celery worker started with PID $!" | |
} | |
# Function to start Celery Beat scheduler | |
start_beat() { | |
echo "Starting Celery Beat scheduler..." | |
python start_celery.py beat & | |
echo "Celery Beat scheduler started with PID $!" | |
} | |
# Function to start both worker and beat | |
start_all() { | |
start_worker | |
start_beat | |
} | |
# Function to check system requirements | |
check_requirements() { | |
echo "Checking system requirements..." | |
python start_celery.py check | |
} | |
# Main script logic | |
case "$1" in | |
worker) | |
start_worker | |
;; | |
beat) | |
start_beat | |
;; | |
all) | |
start_all | |
;; | |
check) | |
check_requirements | |
;; | |
*) | |
echo "Usage: $0 {worker|beat|all|check}" | |
echo " worker - Start Celery worker" | |
echo " beat - Start Celery Beat scheduler" | |
echo " all - Start both worker and scheduler" | |
echo " check - Check system requirements" | |
exit 1 | |
;; | |
esac |