rwadurian/backend
hailin ee07b52af9 feat(mining-2.0): 支持 standalone 独立部署模式,2.0 服务可脱离 1.0 单独运行
## 背景
2.0 挖矿生态需要从 1.0 服务器(192.168.1.111)迁移到独立服务器(192.168.1.10),
实现物理隔离部署。2.0 拥有独立的 PostgreSQL/Redis,通过远程 Kafka 接收 1.0 CDC 数据。

## docker-compose.2.0.yml 变更

### 网络参数化
- 网络改为 external: true + name 参数化:
  `name: ${RWA_NETWORK_NAME:-services_rwa-network}`
- shared 模式复用 1.0 网络, standalone 模式使用独立 rwa-2-network

### 基础设施地址参数化 (所有 7 个 backend service)
- DATABASE_URL: @${POSTGRES_HOST:-postgres}:${POSTGRES_PORT:-5432}
- REDIS_HOST: ${REDIS_HOST:-redis}
- KAFKA_BROKERS: ${KAFKA_BROKERS:-kafka:29092}

### 新增 3 个 standalone profile 基础设施服务
- postgres-2: PostgreSQL 16, WAL logical, init-multiple-dbs.sh 自动建库
- redis-2: Redis 7, appendonly 持久化
- debezium-2: Debezium Connect 2.4, 连接远程 Kafka(192.168.1.111:9093)
  用于 2.0 内部 outbox 模式 (服务事件 → Kafka → mining-admin-service)

### 可选依赖
- 应用 service 添加 depends_on postgres-2/redis-2 with required: false
  (Docker Compose v2.20+, shared 模式下自动跳过)

## deploy-mining.sh 变更

### 部署模式切换
- DEPLOY_MODE 环境变量: shared(默认) / standalone
- load_env() 按模式设置基础设施地址和 COMPOSE_ARGS
- shared 模式不 export 变量,避免覆盖容器侧 Docker Compose 默认值

### Kafka 远程操作支持
- run_kafka_cmd() / run_kafka_cmd_stdin(): standalone 模式用临时容器执行 Kafka CLI
- 所有 Kafka 操作函数 (sync_reset, sync_status, cdc_resnapshot, full_reset) 已适配

### 基础设施生命周期管理
- infra_up / infra_down: 独立管理 standalone 基础设施
- services_up(): standalone 模式自动先启动基础设施
- services_down(): standalone 模式同时停止基础设施
- services_clean(): fallback 列表包含 standalone 容器名

### full_reset() standalone 适配
- standalone 模式跳过 1.0 source CDC 操作 (远程 Debezium 管理)
- standalone 使用 debezium_2_offsets offset topic
- 自动启动 debezium-2 后注册 outbox connectors

### 其他
- health_check(): standalone 模式检查本地 PG/Redis 容器 + 远程 Kafka
- show_help(): 新增 DEPLOY_MODE 说明和 infra-up/infra-down 命令
- print_header(): 显示当前 DEPLOY_MODE
- 所有 ~15 处 docker compose 调用统一使用 $COMPOSE_ARGS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 19:32:03 -08:00
..
.claude refactor: simplify mpc-service to gateway mode 2025-12-06 17:16:14 -08:00
api-gateway feat(api-gateway): 添加 mining-admin-upgrade 路由支持股行App版本管理 2026-01-29 12:37:39 -08:00
infrastructure chore(docker): 为 mpc-system、api-gateway、infrastructure 添加时区配置 2025-12-23 18:35:09 -08:00
mpc-system fix(service-party-android): 导出钱包时自动从后端获取空的 partyId 2026-01-29 07:00:01 -08:00
scripts fix(scripts): 修正容器名为 rwa-blockchain-service 2025-12-15 10:34:25 -08:00
services feat(mining-2.0): 支持 standalone 独立部署模式,2.0 服务可脱离 1.0 单独运行 2026-02-01 19:32:03 -08:00
.env.windows fix(referral): 修复 getMyReferralInfo 使用 userId 而不是 accountSequence 的问题 2025-12-14 05:05:03 -08:00
docker-compose.windows.yml fix(mining-service): Redis DB 11 冲突修复,迁移至 DB 16 2026-01-30 02:22:20 -08:00