#!/bin/bash # 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..." celery -A celery_app worker --loglevel=info & echo "Celery worker started with PID $!" } # Function to start Celery Beat scheduler start_beat() { echo "Starting Celery Beat scheduler..." celery -A celery_beat_config beat --loglevel=info & echo "Celery Beat scheduler started with PID $!" } # Function to start both worker and beat start_all() { start_worker start_beat } # Main script logic case "$1" in worker) start_worker ;; beat) start_beat ;; all) start_all ;; *) echo "Usage: $0 {worker|beat|all}" echo " worker - Start Celery worker" echo " beat - Start Celery Beat scheduler" echo " all - Start both worker and scheduler" exit 1 ;; esac