- src/rag/{unified(21模块),extractors/methodology,project_config} + api/methodology_routes.py(998行)
- 新薄入口 scripts/methodology_server.py(/health + /api/v1/methodology/*)
- env 化补丁:UPLOAD_JOBS_DIR/UPLOAD_OUTPUT_ROOT 支持 env 覆盖(数据根迁移免改代码)
- 影子 8001 冒烟:job 列表与生产 8000 完全一致(3/3)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
44 lines
1.4 KiB
Bash
Executable File
44 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# agent/methodology/scripts/start.sh —— Methodology 服务唯一启动接口
|
|
# 用法:bash scripts/start.sh [port] (默认 8000;影子冒烟用 8001)
|
|
set -euo pipefail
|
|
AGENT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
PORT="${1:-8000}"
|
|
ENV_FILE="${METHODOLOGY_ENV_FILE:-$AGENT_ROOT/env/prod.env}"
|
|
LOG_FILE="${METHODOLOGY_LOG_FILE:-/tmp/plantai-agent-methodology-$PORT.log}"
|
|
PID_FILE="$AGENT_ROOT/run/methodology-$PORT.pid"
|
|
PYTHON="${METHODOLOGY_PYTHON:-/home/xzq/miniconda3/envs/gfpy312/bin/python}"
|
|
BIND="${METHODOLOGY_API_HOST:-0.0.0.0}"
|
|
|
|
mkdir -p "$AGENT_ROOT/run"
|
|
[[ -x "$PYTHON" ]] || { echo "Methodology Python 不可执行: $PYTHON" >&2; exit 1; }
|
|
[[ -f "$ENV_FILE" ]] || { echo "缺少 env 文件: $ENV_FILE" >&2; exit 1; }
|
|
|
|
if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
|
|
echo "Methodology 已在运行 pid=$(cat "$PID_FILE")" >&2
|
|
exit 1
|
|
fi
|
|
|
|
set -a
|
|
# shellcheck disable=SC1090
|
|
. "$ENV_FILE"
|
|
set +a
|
|
|
|
cd "$AGENT_ROOT"
|
|
setsid "$PYTHON" -m uvicorn scripts.methodology_server:app \
|
|
--host "$BIND" --port "$PORT" \
|
|
> "$LOG_FILE" 2>&1 < /dev/null &
|
|
echo $! > "$PID_FILE"
|
|
disown
|
|
|
|
for _ in $(seq 1 20); do
|
|
if curl -sf --max-time 3 "http://127.0.0.1:$PORT/health" >/dev/null 2>&1; then
|
|
echo "Methodology UP ($BIND:$PORT, pid=$(cat "$PID_FILE"))"
|
|
exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo "Methodology FAIL —— 日志尾部:" >&2
|
|
tail -30 "$LOG_FILE" >&2
|
|
exit 1
|