    #!/bin/bash

    # 停止所有服务脚本

    set -e

    SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
    TEST_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
    cd "$TEST_DIR"

    # 检查 docker compose 命令
    if ! docker compose version &> /dev/null 2>&1; then
        echo "错误: 未找到 docker compose 命令，请确保 Docker Compose V2 已安装"
        exit 1
    fi

    echo "=========================================="
    echo "  停止 Argus Metrics 服务"
    echo "=========================================="
    echo ""
    echo "使用: docker compose"
    echo "Compose 文件: $TEST_DIR/docker-compose.yml"
    echo ""

    # 检查是否有运行的容器
    if [ "$(docker compose ps -q)" ]; then
        echo "停止所有服务..."
        docker compose stop
        
        echo ""
        read -p "是否要删除容器? (y/N): " -n 1 -r
        echo
        if [[ $REPLY =~ ^[Yy]$ ]]; then
            docker compose down
            echo "容器已删除"
            
            read -p "是否要删除数据卷? (y/N): " -n 1 -r
            echo
            if [[ $REPLY =~ ^[Yy]$ ]]; then
                docker compose down -v
                echo "数据卷已删除"
            fi
        fi
    else
        echo "没有运行的服务"
    fi

    echo ""
    echo "完成！"

