#!/usr/bin/env bash
# LambdaAgentPaaS — 停止服务
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
ENV_FILE="${HOME}/.agentpaas/.env"

# 加载 DATA_DIR
export AGENTPAAS_DATA_DIR="${HOME}/.agentpaas/data"
[[ -f "$ENV_FILE" ]] && { set -a; source "$ENV_FILE"; set +a; }

COMPOSE_CMD="docker compose"
command -v docker-compose &>/dev/null && ! docker compose version &>/dev/null 2>&1 \
  && COMPOSE_CMD="docker-compose"

cd "$PROJECT_DIR"
echo "⏹  停止 LambdaAgentPaaS..."
$COMPOSE_CMD down
echo "✅ 已停止。数据保留在: ${AGENTPAAS_DATA_DIR}"
