build-flow.api/run-dev.sh

30 lines
1.2 KiB
Bash
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.

#!/bin/bash
# BuildFlow Host 启动脚本(从项目根 .env 加载连接配置)
set -e
# 定位项目根目录(.env 所在)
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
ENV_FILE="$PROJECT_ROOT/.env"
# 1. 清掉可能残留的未展开模板 env 变量,避免脏值干扰
unset $(env | grep -E '^Ai__|^Ai_|^S3__|^Jwt__|^RabbitMq__|^OpenTelemetry__|^ConnectionStrings__|^Cookie__|^FileService__|^REDIS_|^INFRA_|^PG_|^MONGO_|^AI_' | cut -d= -f1)
# 2. 加载项目根 .env(含 PG/Redis/MQ 等连接配置,指向配置服务器)
if [ -f "$ENV_FILE" ]; then
set -a
# shellcheck disable=SC1090
source "$ENV_FILE"
set +a
echo "[run-dev] 已加载 $ENV_FILE"
else
echo "[run-dev] ⚠ 未找到 $ENV_FILE,使用各模块 appsettings.json 的默认(localhost)连接"
fi
# 3. dotnet 的层级配置用 __ 双下划线,.env 里已用 ConnectionStrings__Rag 等变量定义各库连接串,
# .NET 配置系统会自动读取环境变量覆盖 appsettings.json,无需在此重复 export。
# 4. 启动 BuildFlow Host(路径为 src/BuildFlow.Host)
cd "$SCRIPT_DIR/src/BuildFlow.Host"
exec dotnet run --urls http://localhost:5200