rwadurian/backend/services
hailin af896db36c fix(mpc-service): don't await consumer.run() to prevent app startup blocking
consumer.run() never resolves as it runs continuously. Awaiting it
blocks onApplicationBootstrap which prevents app.listen() from being
called, causing the service to never start listening on port 3006.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 03:04:48 -08:00
..
.claude fix(mpc-service): change healthcheck from wget to curl 2025-12-06 23:42:48 -08:00
admin-service fix: convert deploy.sh CRLF to LF and add executable permission 2025-12-07 07:01:13 -08:00
authorization-service feat(withdrawal): implement withdrawal order and fund allocation system 2025-12-09 02:35:27 -08:00
backup-service refactor: unify docker-compose configs to use shared infrastructure 2025-12-07 00:35:56 -08:00
blockchain-service feat(deposit): add deposit balance API and Kafka consumer for deposit events 2025-12-09 02:29:31 -08:00
docs docs(services): add MPC integration verification report 2025-12-04 23:56:21 -08:00
identity-service docs(identity): update KAVA address format comments to EVM 2025-12-08 23:05:47 -08:00
leaderboard-service fix: convert deploy.sh CRLF to LF and add executable permission 2025-12-07 07:01:13 -08:00
mpc-service fix(mpc-service): don't await consumer.run() to prevent app startup blocking 2025-12-09 03:04:48 -08:00
planting-service feat(withdrawal): implement withdrawal order and fund allocation system 2025-12-09 02:35:27 -08:00
presence-service fix: convert deploy.sh CRLF to LF and add executable permission 2025-12-07 07:01:13 -08:00
referral-service feat(withdrawal): implement withdrawal order and fund allocation system 2025-12-09 02:35:27 -08:00
reporting-service fix: convert deploy.sh CRLF to LF and add executable permission 2025-12-07 07:01:13 -08:00
reward-service feat(withdrawal): implement withdrawal order and fund allocation system 2025-12-09 02:35:27 -08:00
scripts fix(blockchain-service): auto-create database and run migrations on startup 2025-12-07 01:14:50 -08:00
wallet-service feat(withdrawal): implement withdrawal order and fund allocation system 2025-12-09 02:35:27 -08:00
.env.example chore: update MinIO credentials in .env.example files 2025-12-07 23:22:45 -08:00
.gitignore refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
README.md refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing 2025-12-05 08:11:28 -08:00
deploy.sh feat(services): add infra-clean and infra-reset commands 2025-12-07 08:56:36 -08:00
docker-compose.infra.yml feat(identity): store complete deviceInfo JSON from frontend 2025-12-07 11:08:37 -08:00
docker-compose.yml feat(deposit): add deposit balance API and Kafka consumer for deposit events 2025-12-09 02:29:31 -08:00
init-multiple-dbs.sh feat(identity): store complete deviceInfo JSON from frontend 2025-12-07 11:08:37 -08:00

README.md

RWA Backend Services

统一部署管理 RWA 后端微服务。

架构概览

┌─────────────────────────────────────────────────────────────────┐
│                    192.168.1.100 (Gateway)                       │
│  ┌─────────────┐  ┌─────────────────────────────────────────┐  │
│  │   Nginx     │  │          MPC-System (Go)                 │  │
│  │  (Reverse   │  │  - session-coordinator (:8081)           │  │
│  │   Proxy)    │  │  - message-router (:8082)                │  │
│  │             │  │  - server-party-1/2/3 (:8083-8085)       │  │
│  └─────────────┘  │  - account-service (:8080)               │  │
│                   └─────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────────┘
                              │
                              │ Internal Network
                              ▼
┌─────────────────────────────────────────────────────────────────┐
│                    192.168.1.111 (Backend)                       │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │              Docker Compose Services                     │    │
│  │  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐       │    │
│  │  │  PostgreSQL │ │    Redis    │ │    Kafka    │       │    │
│  │  │   (:5432)   │ │   (:6379)   │ │   (:9092)   │       │    │
│  │  └─────────────┘ └─────────────┘ └─────────────┘       │    │
│  │                                                          │    │
│  │  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐       │    │
│  │  │  identity   │ │   wallet    │ │   backup    │       │    │
│  │  │  (:3000)    │ │  (:3001)    │ │  (:3002)    │       │    │
│  │  └─────────────┘ └─────────────┘ └─────────────┘       │    │
│  │                                                          │    │
│  │  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐       │    │
│  │  │  planting   │ │  referral   │ │   reward    │       │    │
│  │  │  (:3003)    │ │  (:3004)    │ │  (:3005)    │       │    │
│  │  └─────────────┘ └─────────────┘ └─────────────┘       │    │
│  │                                                          │    │
│  │  ┌─────────────┐ ┌─────────────┐ ┌─────────────┐       │    │
│  │  │    mpc      │ │ leaderboard │ │  reporting  │       │    │
│  │  │  (:3006)    │ │  (:3007)    │ │  (:3008)    │       │    │
│  │  └─────────────┘ └─────────────┘ └─────────────┘       │    │
│  │                                                          │    │
│  │  ┌─────────────┐ ┌─────────────┐                        │    │
│  │  │authorization│ │   admin     │                        │    │
│  │  │  (:3009)    │ │  (:3010)    │                        │    │
│  │  └─────────────┘ └─────────────┘                        │    │
│  └─────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────┘

快速开始

1. 首次安装

# 进入服务目录
cd ~/rwadurian/backend/services

# 运行安装(自动生成安全密钥)
./deploy.sh install

2. 构建镜像

./deploy.sh build

3. 启动服务

./deploy.sh up

4. 检查状态

./deploy.sh status
./deploy.sh health

常用命令

命令 说明
./deploy.sh install 首次安装,生成配置
./deploy.sh build 构建所有 Docker 镜像
./deploy.sh up 启动所有服务
./deploy.sh down 停止所有服务
./deploy.sh restart 重启所有服务
./deploy.sh status 查看服务状态
./deploy.sh health 检查服务健康
./deploy.sh logs 查看所有日志
./deploy.sh logs <service> 查看指定服务日志
./deploy.sh migrate 运行数据库迁移
./deploy.sh rebuild-svc <name> 重建指定服务

服务列表

服务 端口 说明
identity-service 3000 身份认证服务
wallet-service 3001 钱包账本服务
backup-service 3002 MPC 备份服务
planting-service 3003 认种服务
referral-service 3004 推荐系统服务
reward-service 3005 奖励服务
mpc-service 3006 MPC 中间层服务
leaderboard-service 3007 排行榜服务
reporting-service 3008 报表服务
authorization-service 3009 授权服务
admin-service 3010 管理后台服务

基础设施

服务 端口 说明
PostgreSQL 5432 主数据库
Redis 6379 缓存/会话
Kafka 9092 消息队列
Zookeeper 2181 Kafka 协调

环境配置

配置文件 .env./deploy.sh install 自动生成,包含:

  • 数据库密码
  • JWT 密钥
  • 加密密钥
  • MPC 系统地址

重要: .env 文件包含敏感信息,请勿提交到 Git

与 MPC-System 集成

mpc-service 需要连接到运行在 192.168.1.100 上的 MPC-System

  • Session Coordinator: http://192.168.1.100:8081
  • Message Router: ws://192.168.1.100:8082

确保 192.168.1.111 能够访问 192.168.1.100 的这些端口。

故障排除

查看服务日志

./deploy.sh logs identity-service

重建单个服务

./deploy.sh rebuild-svc mpc-service

数据库连接问题

# 进入 postgres 容器
docker exec -it rwa-postgres psql -U rwa_user -d rwa_identity

清理重新开始

./deploy.sh clean  # 删除所有容器和数据
./deploy.sh install
./deploy.sh build
./deploy.sh up