#!/usr/bin/env bash
# AI 建站 — 重启（不拉代码：停 → 构建 → 起）
# 用法：./restart.sh [--rebuild]
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
# shellcheck disable=SC1091
. "$ROOT/scripts/lib-aijz-deploy.sh"

REBUILD=1
for a in "$@"; do
  case "$a" in
    --no-rebuild) REBUILD=0 ;;
    -h|--help)
      echo "用法: $0 [--no-rebuild]"
      exit 0
      ;;
  esac
done

echo "========================================"
echo "  AI 建站 重启"
echo "  路径: $ROOT"
echo "========================================"

ensure_docker
stack_down
sleep 1
stack_up "$REBUILD"
healthcheck
print_endpoints
