#!/bin/bash # Health Probe Simulator Startup Script # This script starts the health probe simulator that continuously sends heartbeats echo "🏥 Starting Health Probe Simulator..." echo "==================================" # Load environment variables if [ -f .env ]; then echo "📋 Loading environment from .env file..." export $(cat .env | grep -v '^#' | xargs) fi # Set defaults if not provided export PROBE_FAILRATE=${PROBE_FAILRATE:-30} export PROBE_INTERVAL_SECONDS=${PROBE_INTERVAL_SECONDS:-60} export API_BASE_URL=${API_BASE_URL:-https://selfservice.cqers.com/drones/api} echo "🔧 Configuration:" echo " Failure Rate: ${PROBE_FAILRATE}%" echo " Probe Interval: ${PROBE_INTERVAL_SECONDS} seconds" echo " API URL: ${API_BASE_URL}" echo "" # Check if running in Docker if [ -n "$DOCKER_CONTAINER" ]; then echo "🐳 Running in Docker container..." # Run with Docker Compose profile docker-compose --profile healthprobe up healthprobe else echo "💻 Running locally..." # Check if Python is available if ! command -v python3 &> /dev/null; then echo "❌ Python 3 is required but not installed" exit 1 fi # Check if requests module is available if ! python3 -c "import requests" &> /dev/null; then echo "📦 Installing requests module..." pip3 install requests fi # Run the health probe simulator echo "🚀 Starting health probe simulator..." python3 health_probe_simulator.py fi