#!/bin/bash # Stop Local Development Services echo "🛑 Stopping Telegram Marketing Intelligence Agent System (Local Mode)" echo "==================================================================" echo "" # Colors GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' echo "1. Stopping Application Services..." echo "----------------------------------" # Stop services using PID files if [ -d "logs" ]; then for pidfile in logs/*.pid; do if [ -f "$pidfile" ]; then service_name=$(basename "$pidfile" .pid) pid=$(cat "$pidfile") echo -n "Stopping $service_name..." if kill $pid 2>/dev/null; then echo -e " ${GREEN}✓${NC}" else echo -e " ${YELLOW}Not running${NC}" fi rm -f "$pidfile" fi done fi # Also kill processes by port (backup method) echo "" echo "2. Cleaning up ports..." echo "----------------------" ports=(3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 5173) for port in "${ports[@]}"; do if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then echo -n "Stopping process on port $port..." lsof -ti:$port | xargs kill -9 2>/dev/null echo -e " ${GREEN}✓${NC}" fi done echo "" echo "3. Stopping Infrastructure Services..." echo "-------------------------------------" echo -n "Stopping Docker infrastructure services..." docker-compose stop mongodb redis rabbitmq elasticsearch prometheus grafana 2>/dev/null echo -e " ${GREEN}✓${NC}" echo "" echo -e "${GREEN}✅ All services stopped!${NC}"