Files
sub2api-cn-relay-manager/scripts
phamnazage-jpg 35447be934
Some checks failed
CI / Build & Test (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Release (push) Has been cancelled
feat(deploy): add CRM-only online deployment to remote43
- scripts/deploy/deploy_crm_only.sh: 单进程部署 sub2api-cn-relay-manager
  CRM 控制面到 remote43,不依赖 sub2api host / PG / Redis 容器。
  复用 scripts/deploy/remote43_patched_stack_lib.sh 的 env 渲染
  (render_remote43_crm_env),render_crm_only_bootstrap 用 $\{VAR\} 占位符 +
  sed 注入避开 set -u + unquoted-heredoc 边缘问题。
  部署前先 kill 老进程 (再 scp 二进制) 避免 ELF overwrite 失败。

- docs/DEPLOYMENT.md: 加 '在线部署节点' 段,记录 stack / 端口 / 入口 / 验证。
- docs/EXECUTION_BOARD.md: 顶部加 'Latest Online Stack' 段。
- artifacts/online-deploy-20260602/: 本次真实部署的证据
  - 01-local-build.txt: 本地 server 二进制 md5 + git head
  - 02-remote-inspect.txt: 远端 process / port / db tables
  - 03-crm-api-checks.txt: /healthz /api/packs /api/hosts /metrics 真实响应
  - 04-portal-public.txt: sub.tksea.top 公共入口
  - 05-quality-gates.txt: gofmt / vet / test -race / integration
  - manifest.json: 结构化汇总

验证(2026-06-02 21:32-21:43):
- /healthz: HTTP 200 'ok'
- /api/packs (Bearer): HTTP 200 '{"packs":[]}'
- /api/hosts (Bearer): HTTP 200 '{"hosts":[]}'
- /api/packs (no auth): HTTP 401
- /metrics (Prometheus): HTTP 200,含 active_hosts/active_providers/
  db_connections_active + Go runtime
- sub.tksea.top/portal/: HTTP 200
- sub.tksea.top/portal-admin-api/healthz: HTTP 200 'ok'(反代到 CRM)
- go test -race ./internal/... ./tests/integration/...: PASS
- gofmt / go vet: 干净
2026-06-02 21:46:39 +08:00
..

scripts 目录说明

日期2026-05-27

scripts/ 当前按职责拆成三层,避免部署、验收和回归入口继续平铺混杂。

目录划分

  • scripts/deploy/
    • 部署、构建、远端环境拉起
    • 例如:
      • build_local_image.sh
      • deploy_tksea_portal.sh
      • setup_remote43_patched_stack.sh
    • 其中 setup_remote43_patched_stack.sh 现会同时准备 remote43 上固定的 Git checkout 路径:
      • /home/ubuntu/sub2api-cn-relay-manager-git-current
      • 供 CRM SUB2API_CRM_REPO_ROOT 与 provider 草稿发布链共用
  • scripts/acceptance/
    • 真实宿主验收、upstream 直探、artifact 安全化
    • 例如:
      • real_host_acceptance.sh
      • import_remote43_provider.sh
      • verify_provider_admin_actions.sh
      • check_deepseek_completion_split.sh
  • scripts/test/
    • 脚本自身的回归与资产检查
    • 例如:
      • test_real_host_scripts.sh
      • test_tksea_portal_assets.sh
      • verify_quality_gates.sh

放置规则

  • 新增脚本前先判断它属于 deployacceptance 还是 test
  • 需要被目标机直接消费的静态文件不要放这里,应放到 deploy/
  • 真实验收产物不要放这里,应落到 artifacts/

常用入口

bash ./scripts/test/test_real_host_scripts.sh
bash ./scripts/test/test_tksea_portal_assets.sh
bash ./scripts/test/verify_quality_gates.sh
scripts/deploy/build_local_image.sh
bash ./scripts/acceptance/real_host_acceptance.sh
bash ./scripts/acceptance/verify_provider_admin_actions.sh

统一质量门禁

scripts/test/verify_quality_gates.sh 是当前推荐的一键测试入口,职责是:

  • 统一执行:
    • gofmt -l .
    • go vet ./...
    • go test -cover ./internal/...
    • go test ./tests/integration/... -count=1
  • 读取 tests/quality/coverage_thresholds.tsv
  • 输出 coverage gate 报告到临时目录
  • 对 core 包覆盖率做硬门槛,对 watch 包做显式告警