#!/bin/bash # Water Management System IoT Layer Stop Script set -e echo "🛑 Stopping Water Management System IoT Layer..." # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Function to print colored output print_status() { echo -e "${GREEN}[INFO]${NC} $1" } print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" } print_error() { echo -e "${RED}[ERROR]${NC} $1" } # Navigate to project directory cd "$(dirname "$0")/.." # Stop Spring Boot application if running if [ -f .spring-boot.pid ]; then SPRING_BOOT_PID=$(cat .spring-boot.pid) if ps -p $SPRING_BOOT_PID > /dev/null; then print_status "Stopping Spring Boot application (PID: $SPRING_BOOT_PID)..." kill $SPRING_BOOT_PID rm .spring-boot.pid print_status "Spring Boot application stopped." else print_warning "Spring Boot application PID $SPRING_BOOT_PID not found." rm -f .spring-boot.pid fi fi # Stop Docker services print_status "Stopping Docker services..." docker-compose down print_status "Water Management System IoT Layer stopped successfully!" echo "" echo "🔧 System has been stopped." echo "" echo "To restart the system:" echo "- cd $(pwd)" echo "- ./scripts/start.sh"