Files
PlantAI-rag-new/deploy/bff_restart.sh
T
jerryandClaude Fable 5 1e94de7464 PlantAI-rag-new 首次提交:文献知识工作台
- BFF 薄适配层(FastAPI,8090):QA 代理/SSE 中继/Neo4j 直连/抽取代理/会话持久化
- Vue3 前端:五相位检索流水线、文献来源与证据链、知识图谱、提取任务四 tab
- 四档响应式(桌面/笔记本/平板/手机)、深浅主题
- 81 个 FR 全部实现,测试追溯矩阵 81/81,后端 121 测/前端 156 测
- 真实凭据已脱敏,运行时配置在 backend/.env(不入 git)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 20:47:52 +08:00

39 lines
1.5 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
# deploy/bff_restart.sh —— 远端 BFF 重启(PM 使用,在远端执行)
# 用法:ssh 192.168.0.175 -p 26518 'bash ~/5090/teamWorkspace/zh/PlantAI-rag-new/deploy/bff_restart.sh [bind_addr]'
# 参数:可选绑定地址(默认 127.0.0.1;内网演示传 0.0.0.0)
# 要点:用 setsid 完全脱离 SSH 会话,stdout/stderr 全部落日志。
set -uo pipefail
ROOT="/home/xzq/5090/teamWorkspace/zh/PlantAI-rag-new"
BIND="${1:-127.0.0.1}"
source ~/miniconda3/etc/profile.d/conda.sh
conda activate plantai-bff
# 杀旧进程([u] 正则技巧防 pkill 自匹配)
pkill -f "[u]vicorn app.main:app" 2>/dev/null
sleep 2
cd "$ROOT/backend"
# 加载运行时凭据(backend/.env,不入 git)并导出给应用进程。
# pydantic-settings 会把 .env 载入 settings 对象,但 services/neo4j.py 的
# _env() 直接读 os.environ,故需显式 set -a 导出。
set -a
[ -f .env ] && source .env
set +a
setsid python -m uvicorn app.main:app --host "$BIND" --port 8090 \
> /tmp/plantai-bff.log 2>&1 < /dev/null &
disown
sleep 5
if ss -tln | grep -q ":8090 "; then
echo "BFF UP ($BIND:8090)"
curl -s --max-time 20 http://127.0.0.1:8090/api/health | head -c 200
echo
# 生产形态:静态托管 frontend/dist(存在时 BFF 单进程服务整个前端)
curl -s --max-time 10 http://127.0.0.1:8090/ | grep -o "<title>[^<]*" || echo "(静态托管未生效,需同步 dist)"
else
echo "BFF FAIL —— 日志尾部:"
tail -15 /tmp/plantai-bff.log
exit 1
fi