跳到主要内容

目标 A:控制面全在 ECS — 迁回 checklist

目标 A:登录、Copilot、项目/数据 API、埋点、管理、工具元数据 尽量走 ECS platform-server (:3011) + ECS Docker PostgreSQLDell 仅 Worker + R/py 算力 + 本地结果文件/缓存/临时目录(见 docs/ops/ECS-PLATFORM-CONVERGENCE-PLAN.md)。

当前(2026-06-13)/api/platform/auth/ai/admin/analytics/public/ 已在 ECS platform :3011,且已通过公网 nginx 与 ECS 直连探针验证。历史上这些路径曾临时指到 Dell :3001 止血, 下面保留旧 checklist 作为迁移记录,不再代表当前待办。/api/platform/tools/* 已拆成 ECS 显式路由;Dell 只通过 internal token 承担执行、结果文件和 demo asset 读取。

P0 已落地(2026-06-07)

  • db.js: getUserByUsernameAsync / getUserByIdAsync / createUserAsync
  • auth.js: login / register / me → async
  • permissions.js: copilot gate → _enforceAsync when isPg()
  • helpers/conversations-async.js + agent 会话 create/append user msg(BIOF3_P2_PG=1
  • ECS 127.0.0.1:3011 login ~0.15s(401 错密)
  • nginx auth + ai → 3011(2026-06-07);公网 login ~0.19s,agent 首包 ~3s
  • admin / analytics / public 已迁回 ECS platform 并复验
  • agent 登录用户全链路(snapshot/facts/plans 等仍需按实际模块持续巡检)

1. 完成定义(Done)

#验收项方法
D1公网 POST /api/platform/auth/login < 2s 返回 JSONcurl,仅 ECS 路径(nginx 无 Dell 例外)
D2公网 POST /api/platform/ai/agent < 3s 出现首条 SSEcurl -N
D3登录用户 GET /api/platform/ai/conversations 200admin JWT
D4GET /api/platform/admin/top-ips 200admin JWT
D5POST /api/platform/analytics/page-view 200(可匿名)无 token
D6nginx `platform/authai
D7Dell biof3-r-server / biof3-py-serverapi 算力/内部路由,biof3-r-worker / biof3-py-workerworker不再承担全站 API 网关pm2 + BIOF3_RUN_MODE

2. 阻塞项(按优先级)

P0 — 不修则 ECS platform 不可用

说明主要文件
deasync 热路径getSqliteForLegacyModules() + BIOF3_P2_PG=1 在 HTTP 里 deasync.loopWhile 查 PGdb.js, db-p2-pg-shim.js
auth/login同步 getUserByUsernameauth.js(P0 用户已 async PG,但 platform 进程仍可能卡在 P2 初始化/混用)
ai-agent 入口建会话、facts、summary、plans 同步查routes/ai-agent.js, helpers/conversations.js

方向(二选一或组合)

  • 短期:platform 上 P2 热路径改为 async 路由async (req,res) + await pgPool.query),不再经 sync shim。
  • 中期:Copilot/会话类表专用 db-p2-async.js 模块,platform 只引 async 版;worker 仍可 sync/aux 至 cutover 完成。

P1 — 已部分修;迁回前全量扫

说明
db vs sqlite路由里 const {db} = require('../db') + db.prepare 会炸(db 是 better-sqlite 连接对象)。统一 sqlite = getSqliteForLegacyModules() 或 async PG。已修:conversations, ai-plans, ai-memory, chat-summary需 grep 扫全 r-server/routes
PG boolean / timestamptzadmin 统计等 SQL 勿写 undone=1substr(ts,1,10)
ECS envDATABASE_URL, JWT_SECRET, BIOF3_P2_PG=1, BIOF3_RUN_MODE=platform, 不要依赖本机 biof3.db 写用户

P2 — 体验与运维

说明
docs-indexagent 启动拉 copilot-index.json(公网),慢但不致命;可缓存/内置
frp迁回 ECS 后,frp 仅需 Dell 算力端口(3001 若只给 /api/r/ worker API)
PostgreSQL 连接当前中心库是 ECS Docker PostgreSQL;ECS 本机连接,Dell worker 通过受控 autossh/VPN/专线连接
platform 与 Dell JWT必须同一 JWT_SECRET(已要求)

3. nginx 回切步骤(D6,历史记录)

文件infra/nginx/biof3.conf → 同步到 ECS /opt/biof3/app/nginx/biof3.conf(注意必须是文件不是目录)。

已删除或避免的 Dell 控制面例外

  • location /api/platform/auth/ → 3001
  • location /api/platform/ai/ → 3001
  • location /api/platform/admin/ → 3001
  • location /api/platform/analytics/ → 3001
  • location /api/platform/public/ → 3001

保留

  • location /api/platform/172.17.0.1:3011/api/
  • location /api/platform/tools/<known-route> → ECS 显式路由;最终 /api/platform/tools/ fallback 返回 404
  • location /api/r/ → 3001(算力)
  • location /api/r/auth/404(旧认证兼容入口已退役,避免被 /api/r/ catch-all 转到 Dell)
  • location /api/py/ → 3002
docker exec biof3-nginx nginx -t && docker exec biof3-nginx nginx -s reload

4. Dell 降级(D7)

  1. ECS platform 已通过 D1–D5。
  2. Dell:biof3-r-server 使用 BIOF3_RUN_MODE=api,只保留 /api/r/* 算力兼容和 /api/internal/* Dell-local ops;不再本机 drain task queue。
  3. pm2:biof3-r-worker 保持 BIOF3_RUN_MODE=worker,负责认领 PG 队列并跑 R Docker。
  4. Dell:biof3-py-server 使用 BIOF3_RUN_MODE=api,只保留 /api/py/* Python compute API;不再本机 drain task queue。
  5. pm2:biof3-py-worker 保持 BIOF3_RUN_MODE=worker,负责认领 PG 队列并跑 Python Docker。
  6. 文档更新 ARCH-api-worker.md 与 steering infrastructure.md

5. 建议实施顺序

Week 1 P0: auth + ai/agent async PG(或 platform 专用 async 层)
P1: routes 全量 db→sqlite/async 扫描 + 单测/smoke
Week 2 ECS 压测 D1–D5 → nginx 回切 D6
Dell worker 模式 D7
删 nginx Dell 例外,监控 24h

Smoke 脚本(可扩展):test/smoke-platform-split.mjs、对 https://biof3.com/api/platform/* 的 curl 列表。


6. 不在目标 A 范围内

  • R site-library / Seurat 全部迁到 ECS(算力仍 Dell 或大内存云)。
  • 去掉 frp 算力通道(除非 worker 改公网/VPN 专线另一种组网)。

7. 相关文档

AI 组学实践

让 AI 带我实战这一篇

AI 会读这篇文章后给你 3-5 步学习计划, 逐步带你学完,最后出 1-3 道题验证你掌握得怎么样。 登录后 AI 才能记住你的进度。

静态文件

离线资料下载

手册 HTML / PDF 已在后台预生成,点击后直接下载网站静态资源。