feat: move report artifacts to OSS storage
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
## 前置条件
|
||||
|
||||
- DNS:`WEB_PUBLIC_HOST` 指向部署主机;
|
||||
- PostgreSQL 15+:目标必须是隔离数据库 `booking_test`,并已应用 008–012 权威迁移;
|
||||
- PostgreSQL 15+:目标必须是隔离数据库 `booking_test`,并已应用 008–016 权威迁移;
|
||||
- OSS:区域匹配、服务端加密、未启用或暂停 versioning、禁止匿名写;bucket ACL 可为 private 或 public-read;
|
||||
- ARR 数据库账号和 OSS RAM/STS 凭据由 Secret 管理器注入,不写入镜像或仓库。
|
||||
- 公司渠道明细由 Web 进程使用 Python/openpyxl 生成正式 Excel;不需要 Node.js 或 `@oai/artifact-tool`。
|
||||
- worker 与 Web 使用同一数据库和共享的 `/app/outputs` 持久卷;月报 worker 镜像还必须包含 Node.js 与配置匹配的 artifact-tool 模块。
|
||||
- 月报和公司渠道明细均由 Python/openpyxl 生成;不需要 Node.js、npm 或私有运行时。
|
||||
- 月报/公司 XLSX 与 `result.json` 上传现有 OSS;只有 `.web-jobs` 队列状态和临时 staging 继续使用 `/app/outputs` 持久卷。
|
||||
|
||||
## 配置
|
||||
|
||||
@@ -25,6 +25,18 @@ chmod 600 deploy/.env.production
|
||||
- Agent callback URL/HMAC;
|
||||
- `fetch_oss_file` 或源文件公网 URL。
|
||||
|
||||
## 应用月报 OSS 迁移
|
||||
|
||||
在目标数据库确认当前连接为隔离的 `booking_test` 后,先应用 016;脚本会自行拒绝其他数据库。016
|
||||
只替换月报发布校验函数,不新增表或列,历史 `local` 工件不需要迁移:
|
||||
|
||||
```bash
|
||||
psql "$ARR_DATABASE_URL" -Atc "select current_database();"
|
||||
sha256sum database/016_monthly_report_oss_artifacts.sql
|
||||
psql "$ARR_DATABASE_URL" -v ON_ERROR_STOP=1 \
|
||||
-f database/016_monthly_report_oss_artifacts.sql
|
||||
```
|
||||
|
||||
## 校验并启动
|
||||
|
||||
```bash
|
||||
@@ -33,13 +45,21 @@ docker compose --env-file deploy/.env.production build web
|
||||
docker compose --env-file deploy/.env.production up -d
|
||||
```
|
||||
|
||||
当前仓库镜像未内置 Codex 工作站提供的 artifact-tool,因此 Compose 模板不会虚假启动一个无法生成 XLSX 的 worker。部署环境完成该依赖打包后,应由 systemd、容器编排器或同等进程管理器独立执行:
|
||||
Compose 启动后,应由 systemd、容器编排器或同等进程管理器独立执行月报 worker:
|
||||
|
||||
```bash
|
||||
python -m monthly_reports.worker \
|
||||
--db-config /run/secrets/booking-test-db.env \
|
||||
--node-binary /absolute/path/to/node \
|
||||
--artifact-tool-module /absolute/path/to/artifact_tool.mjs \
|
||||
docker compose --env-file deploy/.env.production run --rm web \
|
||||
python -m monthly_reports.worker \
|
||||
--output-root /app/outputs/monthly_reports
|
||||
```
|
||||
|
||||
该命令沿用 Compose 注入的 `ARR_DATABASE_URL`、`ARR_OSS_*` 和 OSS 凭据;如果改由主机上的 systemd 运行,
|
||||
则在进程环境中提供同一组变量,或显式传入受控的 `--db-config` 文件。`--once` 可用于部署后的单次探针:
|
||||
|
||||
```bash
|
||||
docker compose --env-file deploy/.env.production run --rm web \
|
||||
python -m monthly_reports.worker \
|
||||
--once \
|
||||
--output-root /app/outputs/monthly_reports
|
||||
```
|
||||
|
||||
@@ -50,7 +70,7 @@ curl --fail --silent "https://$WEB_PUBLIC_HOST/healthz"
|
||||
docker compose --env-file deploy/.env.production logs --tail=100 web
|
||||
```
|
||||
|
||||
`/healthz` 仅以 HTTP 200/503 表示数据库与处理入口是否就绪,不暴露组件详情;详细 `/api/health` 必须登录后访问。worker 是独立进程,应另行监控其存活和 outbox 的 `pending/publishing/dead` 数量。失败时优先检查登录环境变量、数据库目标、OSS 区域/加密/versioning、OSS 凭据、固定处理器以及月报构建依赖;无需排查 Agent 或 MCP。
|
||||
`/healthz` 仅以 HTTP 200/503 表示数据库与处理入口是否就绪,不暴露组件详情;详细 `/api/health` 必须登录后访问。worker 是独立进程,应另行监控其存活和 outbox 的 `pending/publishing/dead` 数量。失败时优先检查登录环境变量、数据库目标、OSS 区域/加密/versioning、OSS 凭据和固定处理器;无需排查 Agent、MCP 或 Node/npm。
|
||||
|
||||
## 验收
|
||||
|
||||
@@ -61,7 +81,7 @@ docker compose --env-file deploy/.env.production logs --tail=100 web
|
||||
3. 上传响应应直接给出 `succeeded` 或 `failed` 终态以及 `job_id`;
|
||||
4. 在任务日志中确认“固定处理器已启动 → 程序输出制品已登记 → 独立验收 → Finance 提交”;
|
||||
5. 成功任务应能下载对应日报,数据库中 source/retained/outcome 数量必须与结构化结果一致;
|
||||
6. worker 应消费对应 outbox 事件,页面显示真实月报 ID/版本/“更新至”,下载文件哈希应与登记值一致;
|
||||
6. worker 应消费对应 outbox 事件,页面显示真实月报 ID/版本/“更新至”,下载文件哈希应与 OSS 登记值一致;删除 Web 容器或清空其临时 `outputs/monthly_reports` 后,月报与公司报表仍应可下载;
|
||||
7. 退出登录后,页面、API 和下载均应重新要求登录;
|
||||
8. 业务失败任务不得激活 Finance 当前版本或触发月报。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user