Files
AI-Testing/start.sh
2026-04-12 20:18:09 +08:00

42 lines
1004 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
echo "==> 构建并启动所有服务..."
docker compose up --build -d
echo "==> 当前容器状态"
docker compose ps
if [[ -f ".env" ]]; then
echo "==> 检测到 .env将覆盖 .env.example 中的同名 AI 变量)"
else
echo "==> AI 配置来自 .env.example请填写 QWEN_API_KEY亦可复制为 .env 再填写)"
fi
wait_http() {
local url=$1
local label=$2
local i=0
while [[ $i -lt 45 ]]; do
if curl -sf "$url" >/dev/null 2>&1; then
echo "${label}: ok"
return 0
fi
sleep 1
i=$((i + 1))
done
echo "${label}: unreachable请确认容器已就绪或执行: curl -v ${url}"
return 1
}
echo "==> 健康检查(后端 8866前端 Nginx 8173最多等待约 45s"
wait_http "http://localhost:8866/health" "backend" || true
wait_http "http://localhost:8173/health" "frontend (nginx)" || true
echo "==> 启动完成"