#!/bin/bash # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${YELLOW}Stopping Foxhunt Services...${NC}" # Function to stop a service stop_service() { local pid_file=$1 local service_name=$2 if [ -f "${pid_file}" ]; then local pid=$(cat "${pid_file}") if kill -0 ${pid} 2>/dev/null; then echo -e "${YELLOW}Stopping ${service_name} (PID: ${pid})...${NC}" kill ${pid} sleep 2 if kill -0 ${pid} 2>/dev/null; then echo -e "${RED}Force killing ${service_name}...${NC}" kill -9 ${pid} fi echo -e "${GREEN}${service_name} stopped${NC}" else echo -e "${YELLOW}${service_name} not running${NC}" fi rm -f "${pid_file}" else echo -e "${YELLOW}${service_name} PID file not found${NC}" fi } # Stop all services stop_service logs/api_gateway.pid "API Gateway" stop_service logs/trading_service.pid "Trading Service" stop_service logs/backtesting_service.pid "Backtesting Service" stop_service logs/ml_training_service.pid "ML Training Service" echo -e "${GREEN}All services stopped${NC}"