Files
PlantAI-rag-new/deploy/bff_restart.sh
T
jerryandClaude Fable 5 0875bb036c P0/M1: 四部分重构——frontend→ui、backend→sdk 改名 + 引用修复 + 骨架
- git mv 保留历史:ui/(Vue3+Vite)、sdk/(BFF 中间层)
- 路径语义修正:db_path/figures_cache 改相对 sdk/(BFF cwd),
  历史库 sdk/backend/data 迁移至 sdk/data/(会话/图片缓存无损)
- 引用修复 ~15 处:config.py、deploy/*.sh、vitest/playwright 配置、
  单测导入路径、docs、README、gitignore、.env.example
- 骨架:agent/{qa,methodology,legacy-rag,vendor}、knowledge/manifest.yaml、
  tooling/{compile,kb,crypto,assemble,audit,tools,scripts} + README
- 门禁验证:sdk pytest 125 通过、ui vitest 158 通过、
  生产 BFF 脚本重启四上游全绿 + 静态托管 + 会话库无损

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-31 12:56:47 +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/sdk"
# 加载运行时凭据(sdk/.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
# 生产形态:静态托管 ui/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