#!/bin/bash

# Start Notification Queue Workers
# This script starts queue workers for both SMS and Email notifications

echo "=========================================="
echo "Starting LaDMA Notification Queue Workers"
echo "=========================================="
echo ""

# Check if artisan exists
if [ ! -f "artisan" ]; then
    echo "Error: artisan file not found. Please run this script from the backend_api directory."
    exit 1
fi

# Clear config cache
echo "Clearing config cache..."
php artisan config:clear
php artisan config:cache
echo "✓ Config cache cleared"
echo ""

# Start queue worker for notifications
echo "Starting queue worker for notifications (SMS & Email)..."
echo "Queue: notifications"
echo "Tries: 3"
echo "Timeout: 60 seconds"
echo ""
echo "Press Ctrl+C to stop the worker"
echo "=========================================="
echo ""

# Start the queue worker
php artisan queue:work --queue=notifications --tries=3 --timeout=60 --verbose
