Commit 4a766e66 by luoqi

chore(ports): renumber to avoid conflicts on shared server

postgres 5432 → 5532
redis    6379 → 6479
service  3001 → 3101
web      3000 → 3100

服务器 47.251.104.47 已有其他项目占用 5432/3001,
统一为新端口段(5532/6479/3101/3100)避免冲突。

容器内部网络通信(postgres:5432, redis:6379)保持不变,
只改宿主机映射 + 应用 PORT 环境变量。
parent 9920577a
# --- Database --- # --- Database ---
DATABASE_URL=postgresql://pac:pac@localhost:5432/pac?schema=public DATABASE_URL=postgresql://pac:pac@localhost:5532/pac?schema=public
# --- Redis --- # --- Redis ---
REDIS_URL=redis://localhost:6379 REDIS_URL=redis://localhost:6479
# --- JWT --- # --- JWT ---
JWT_SECRET=replace-with-strong-random-secret-min-32-chars JWT_SECRET=replace-with-strong-random-secret-min-32-chars
...@@ -18,12 +18,12 @@ AI_GATEWAY_API_KEY= ...@@ -18,12 +18,12 @@ AI_GATEWAY_API_KEY=
# --- Service --- # --- Service ---
NODE_ENV=development NODE_ENV=development
PORT=3001 PORT=3101
LOG_LEVEL=info LOG_LEVEL=info
CORS_ORIGINS=http://localhost:3000 CORS_ORIGINS=http://localhost:3100
# --- One-time code --- # --- One-time code ---
EXCHANGE_CODE_TTL_SECONDS=60 EXCHANGE_CODE_TTL_SECONDS=60
# --- Frontend --- # --- Frontend ---
NEXT_PUBLIC_API_BASE_URL=http://localhost:3001 NEXT_PUBLIC_API_BASE_URL=http://localhost:3101
...@@ -59,16 +59,16 @@ pnpm --filter @pac/service prisma:seed ...@@ -59,16 +59,16 @@ pnpm --filter @pac/service prisma:seed
pnpm dev pnpm dev
``` ```
- Backend: http://localhost:3001 - Backend: http://localhost:3101
- API reference: http://localhost:3001/api/docs (Scalar) - API reference: http://localhost:3101/api/docs (Scalar)
- OpenAPI JSON: http://localhost:3001/api/openapi.json - OpenAPI JSON: http://localhost:3101/api/openapi.json
- Frontend: http://localhost:3000 - Frontend: http://localhost:3100
## Smoke test the auth flow ## Smoke test the auth flow
```bash ```bash
# 1) host backend trades app credentials for a recall_token + one-time code # 1) host backend trades app credentials for a recall_token + one-time code
curl -s -X POST http://localhost:3001/pac/v1/auth/token \ curl -s -X POST http://localhost:3101/pac/v1/auth/token \
-H 'content-type: application/json' \ -H 'content-type: application/json' \
-d '{ -d '{
"appId": "demo-app", "appId": "demo-app",
...@@ -82,22 +82,22 @@ curl -s -X POST http://localhost:3001/pac/v1/auth/token \ ...@@ -82,22 +82,22 @@ curl -s -X POST http://localhost:3001/pac/v1/auth/token \
}' }'
# 2) front-end (or curl) trades the code for the recall_token # 2) front-end (or curl) trades the code for the recall_token
curl -s -X POST http://localhost:3001/pac/v1/auth/exchange-code \ curl -s -X POST http://localhost:3101/pac/v1/auth/exchange-code \
-H 'content-type: application/json' \ -H 'content-type: application/json' \
-d '{ "code": "<paste code from step 1>" }' -d '{ "code": "<paste code from step 1>" }'
# 3) call a protected endpoint — list the recall pool (empty until plan engine runs) # 3) call a protected endpoint — list the recall pool (empty until plan engine runs)
curl -s "http://localhost:3001/pac/v1/plans?view=pool" \ curl -s "http://localhost:3101/pac/v1/plans?view=pool" \
-H "authorization: Bearer <recall_token>" -H "authorization: Bearer <recall_token>"
# 4) drive the pipeline end-to-end: # 4) drive the pipeline end-to-end:
curl -s -X POST http://localhost:3001/pac/v1/sync/trigger \ curl -s -X POST http://localhost:3101/pac/v1/sync/trigger \
-H "authorization: Bearer <recall_token>" -H 'content-type: application/json' \ -H "authorization: Bearer <recall_token>" -H 'content-type: application/json' \
-d '{}' # mock-pull emits ~10 facts → patient_fact_events filled in -d '{}' # mock-pull emits ~10 facts → patient_fact_events filled in
``` ```
To preview the workbench against a fresh code, point the iframe at: To preview the workbench against a fresh code, point the iframe at:
`http://localhost:3000/?code=<one-time-code>`. `http://localhost:3100/?code=<one-time-code>`.
## Scripts ## Scripts
......
...@@ -21,21 +21,21 @@ ...@@ -21,21 +21,21 @@
# production: production ⚠️ 必须设 production,关掉一些开发兜底 # production: production ⚠️ 必须设 production,关掉一些开发兜底
NODE_ENV=development NODE_ENV=development
PORT=3001 PORT=3101
# local: debug | staging+prod: info # local: debug | staging+prod: info
LOG_LEVEL=info LOG_LEVEL=info
# ─── 数据库 / 缓存 ──────────────────────────────────────────────────── # ─── 数据库 / 缓存 ────────────────────────────────────────────────────
# local: postgresql://pac:pac@localhost:5432/pac?schema=public # local: postgresql://pac:pac@localhost:5532/pac?schema=public
# staging: postgresql://pac:<staging-pwd>@<staging-pg-host>:5432/pac?schema=public # staging: postgresql://pac:<staging-pwd>@<staging-pg-host>:5532/pac?schema=public
# production: postgresql://pac:<prod-pwd>@<prod-pg-host>:5432/pac?schema=public # production: postgresql://pac:<prod-pwd>@<prod-pg-host>:5532/pac?schema=public
DATABASE_URL=postgresql://pac:pac@localhost:5432/pac?schema=public DATABASE_URL=postgresql://pac:pac@localhost:5532/pac?schema=public
# local: redis://localhost:6379 # local: redis://localhost:6479
# staging+prod: redis://<host>:6379 (BullMQ 队列用,丢了会丢未消费的 plan-asset-generate 任务) # staging+prod: redis://<host>:6479 (BullMQ 队列用,丢了会丢未消费的 plan-asset-generate 任务)
REDIS_URL=redis://localhost:6379 REDIS_URL=redis://localhost:6479
# ─── JWT(per-env 必须不同强随机)──────────────────────────────────── # ─── JWT(per-env 必须不同强随机)────────────────────────────────────
...@@ -67,10 +67,10 @@ AI_REQUEST_TIMEOUT_SEC=60 ...@@ -67,10 +67,10 @@ AI_REQUEST_TIMEOUT_SEC=60
# ─── CORS / iframe ─────────────────────────────────────────────────── # ─── CORS / iframe ───────────────────────────────────────────────────
# local: http://localhost:3000 # local: http://localhost:3100
# staging: https://pac-staging.<your-domain> # staging: https://pac-staging.<your-domain>
# production: https://pac.<your-domain> (多个用逗号) # production: https://pac.<your-domain> (多个用逗号)
CORS_ORIGINS=http://localhost:3000 CORS_ORIGINS=http://localhost:3100
# iframe 一次性 code TTL(默认 60s) # iframe 一次性 code TTL(默认 60s)
EXCHANGE_CODE_TTL_SECONDS=60 EXCHANGE_CODE_TTL_SECONDS=60
......
...@@ -35,7 +35,7 @@ function parseArgs(argv: string[]): CliArgs { ...@@ -35,7 +35,7 @@ function parseArgs(argv: string[]): CliArgs {
cmd: (argv[0] as CliArgs['cmd']) ?? 'help', cmd: (argv[0] as CliArgs['cmd']) ?? 'help',
host: 'mock-host', host: 'mock-host',
days: 7, days: 7,
apiBase: process.env.PAC_API_BASE_URL ?? 'http://localhost:3001', apiBase: process.env.PAC_API_BASE_URL ?? 'http://localhost:3101',
}; };
for (const a of argv.slice(1)) { for (const a of argv.slice(1)) {
if (a.startsWith('--host=')) out.host = a.slice('--host='.length); if (a.startsWith('--host=')) out.host = a.slice('--host='.length);
...@@ -59,7 +59,7 @@ Commands: ...@@ -59,7 +59,7 @@ Commands:
Options: Options:
--host=<name> host name(default mock-host) --host=<name> host name(default mock-host)
--days=<n> reconcile 时间窗(default 7) --days=<n> reconcile 时间窗(default 7)
--api=<url> (push 模式用)PAC api base url(default http://localhost:3001) --api=<url> (push 模式用)PAC api base url(default http://localhost:3101)
`); `);
} }
......
NEXT_PUBLIC_API_BASE_URL=http://localhost:3001 NEXT_PUBLIC_API_BASE_URL=http://localhost:3101
export const env = { export const env = {
apiBaseUrl: process.env.NEXT_PUBLIC_API_BASE_URL ?? 'http://localhost:3001', apiBaseUrl: process.env.NEXT_PUBLIC_API_BASE_URL ?? 'http://localhost:3101',
}; };
...@@ -34,7 +34,7 @@ sudo mkdir -p /var/log/pac && sudo chown pac:pac /var/log/pac ...@@ -34,7 +34,7 @@ sudo mkdir -p /var/log/pac && sudo chown pac:pac /var/log/pac
```bash ```bash
sudo docker run -d --name pac-postgres --restart unless-stopped \ sudo docker run -d --name pac-postgres --restart unless-stopped \
-p 127.0.0.1:5432:5432 \ -p 127.0.0.1:5532:5432 \
-e POSTGRES_USER=pac \ -e POSTGRES_USER=pac \
-e POSTGRES_PASSWORD=<强密码> \ -e POSTGRES_PASSWORD=<强密码> \
-e POSTGRES_DB=pac \ -e POSTGRES_DB=pac \
...@@ -42,7 +42,7 @@ sudo docker run -d --name pac-postgres --restart unless-stopped \ ...@@ -42,7 +42,7 @@ sudo docker run -d --name pac-postgres --restart unless-stopped \
postgres:15 postgres:15
sudo docker run -d --name pac-redis --restart unless-stopped \ sudo docker run -d --name pac-redis --restart unless-stopped \
-p 127.0.0.1:6379:6379 \ -p 127.0.0.1:6479:6379 \
-v pac-redis-data:/data \ -v pac-redis-data:/data \
redis:7-alpine redis:7-alpine
``` ```
...@@ -97,8 +97,8 @@ sudo -u pac bash /opt/pac/deploy/deploy.sh production ...@@ -97,8 +97,8 @@ sudo -u pac bash /opt/pac/deploy/deploy.sh production
### 6. 验证 ### 6. 验证
```bash ```bash
curl http://localhost:3001/health # 应返 {"status":"ok"} 或类似 curl http://localhost:3101/health # 应返 {"status":"ok"} 或类似
curl http://localhost:3000 # Next.js 首页 HTML curl http://localhost:3100 # Next.js 首页 HTML
journalctl -u pac-service -n 50 -f # 看日志 journalctl -u pac-service -n 50 -f # 看日志
journalctl -u pac-web -n 50 -f journalctl -u pac-web -n 50 -f
``` ```
......
...@@ -103,5 +103,5 @@ echo "════════════════════════ ...@@ -103,5 +103,5 @@ echo "════════════════════════
echo "✓ 部署完成 — $AFTER_HEAD ($(date '+%F %T'))" echo "✓ 部署完成 — $AFTER_HEAD ($(date '+%F %T'))"
echo "═══════════════════════════════════════════════════════════" echo "═══════════════════════════════════════════════════════════"
echo "验证:" echo "验证:"
echo " curl http://localhost:3001/health" echo " curl http://localhost:3101/health"
echo " 打开 https://<your-domain>/plans" echo " 打开 https://<your-domain>/plans"
...@@ -52,7 +52,7 @@ services: ...@@ -52,7 +52,7 @@ services:
condition: service_completed_successfully condition: service_completed_successfully
environment: environment:
NODE_ENV: production NODE_ENV: production
PORT: 3001 PORT: 3101
DATABASE_URL: ${DATABASE_URL} DATABASE_URL: ${DATABASE_URL}
REDIS_URL: ${REDIS_URL} REDIS_URL: ${REDIS_URL}
JWT_SECRET: ${JWT_SECRET} JWT_SECRET: ${JWT_SECRET}
...@@ -64,7 +64,7 @@ services: ...@@ -64,7 +64,7 @@ services:
CORS_ORIGINS: ${CORS_ORIGINS} CORS_ORIGINS: ${CORS_ORIGINS}
EXCHANGE_CODE_TTL_SECONDS: ${EXCHANGE_CODE_TTL_SECONDS:-60} EXCHANGE_CODE_TTL_SECONDS: ${EXCHANGE_CODE_TTL_SECONDS:-60}
ports: ports:
- "3001:3001" - "3101:3101"
pac-web: pac-web:
build: build:
...@@ -77,8 +77,9 @@ services: ...@@ -77,8 +77,9 @@ services:
environment: environment:
NODE_ENV: production NODE_ENV: production
NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL} NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL}
PORT: 3100
ports: ports:
- "3000:3000" - "3100:3100"
volumes: volumes:
postgres_data: postgres_data:
......
...@@ -8,7 +8,7 @@ services: ...@@ -8,7 +8,7 @@ services:
POSTGRES_PASSWORD: pac POSTGRES_PASSWORD: pac
POSTGRES_DB: pac POSTGRES_DB: pac
ports: ports:
- "5432:5432" - "5532:5432"
volumes: volumes:
- postgres_data:/var/lib/postgresql/data - postgres_data:/var/lib/postgresql/data
healthcheck: healthcheck:
...@@ -47,7 +47,7 @@ services: ...@@ -47,7 +47,7 @@ services:
container_name: pac-redis container_name: pac-redis
restart: unless-stopped restart: unless-stopped
ports: ports:
- "6379:6379" - "6479:6379"
volumes: volumes:
- redis_data:/data - redis_data:/data
healthcheck: healthcheck:
...@@ -70,7 +70,7 @@ services: ...@@ -70,7 +70,7 @@ services:
condition: service_healthy condition: service_healthy
environment: environment:
NODE_ENV: development NODE_ENV: development
PORT: 3001 PORT: 3101
DATABASE_URL: postgresql://pac:pac@postgres:5432/pac?schema=public DATABASE_URL: postgresql://pac:pac@postgres:5432/pac?schema=public
REDIS_URL: redis://redis:6379 REDIS_URL: redis://redis:6379
JWT_SECRET: dev-secret-change-me-in-production-min-32-chars JWT_SECRET: dev-secret-change-me-in-production-min-32-chars
...@@ -79,10 +79,10 @@ services: ...@@ -79,10 +79,10 @@ services:
JWT_REFRESH_EXPIRES_IN: 7d JWT_REFRESH_EXPIRES_IN: 7d
AI_GATEWAY_URL: https://ai-gateway.example.com AI_GATEWAY_URL: https://ai-gateway.example.com
AI_GATEWAY_API_KEY: dev-placeholder AI_GATEWAY_API_KEY: dev-placeholder
CORS_ORIGINS: http://localhost:3000 CORS_ORIGINS: http://localhost:3100
EXCHANGE_CODE_TTL_SECONDS: 60 EXCHANGE_CODE_TTL_SECONDS: 60
ports: ports:
- "3001:3001" - "3101:3101"
volumes: volumes:
- ./apps/pac-service:/app/apps/pac-service - ./apps/pac-service:/app/apps/pac-service
- ./packages:/app/packages - ./packages:/app/packages
...@@ -100,9 +100,10 @@ services: ...@@ -100,9 +100,10 @@ services:
- pac-service - pac-service
environment: environment:
NODE_ENV: development NODE_ENV: development
NEXT_PUBLIC_API_BASE_URL: http://localhost:3001 NEXT_PUBLIC_API_BASE_URL: http://localhost:3101
PORT: 3100
ports: ports:
- "3000:3000" - "3100:3100"
volumes: volumes:
- ./apps/pac-web:/app/apps/pac-web - ./apps/pac-web:/app/apps/pac-web
- ./packages:/app/packages - ./packages:/app/packages
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
│ │ │ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Postgres 15 │ │ Redis 7 │ │ pac-web │ │ │ │ Postgres 15 │ │ Redis 7 │ │ pac-web │ │
│ │ :5432 │ │ :6379 │ │ :3000 │ Next.js │ │ │ :5532 │ │ :6479 │ │ :3100 │ Next.js │
│ │ pac DB │ │ BullMQ / │ │ │ prod build│ │ │ pac DB │ │ BullMQ / │ │ │ prod build│
│ │ │ │ session │ │ │ │ │ │ │ │ session │ │ │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │ │ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
│ │ │ │ │ │
│ ┌───────▼────────┐ │ │ ┌───────▼────────┐ │
│ │ pac-service │ NestJS │ │ │ pac-service │ NestJS │
│ │ :3001 │ - HTTP API │ │ │ :3101 │ - HTTP API │
│ │ │ - BullMQ Worker │ │ │ │ - BullMQ Worker │
│ │ │ - Cron(增量同步/监控) │ │ │ │ - Cron(增量同步/监控) │
│ └───────┬────────┘ │ │ └───────┬────────┘ │
...@@ -41,10 +41,10 @@ ...@@ -41,10 +41,10 @@
| 组件 | 端口 | 用途 | 数据敏感度 | | 组件 | 端口 | 用途 | 数据敏感度 |
|---|---|---|---| |---|---|---|---|
| Postgres 15 | 5432 | PAC 主数据(patients / facts / personas / plans / sync_logs) | 🔴 PII | | Postgres 15 | 5532 | PAC 主数据(patients / facts / personas / plans / sync_logs) | 🔴 PII |
| Redis 7 | 6379 | BullMQ 队列 + 会话 | 🟡 session token | | Redis 7 | 6479 | BullMQ 队列 + 会话 | 🟡 session token |
| pac-service | 3001 | API + Cron + Worker | — | | pac-service | 3101 | API + Cron + Worker | — |
| pac-web | 3000 | 前端(Next.js) | — | | pac-web | 3100 | 前端(Next.js) | — |
| (远程)瑞尔 DW | 9000 | 数据源(只读),PAC 主动连 | 🔴 PII(只读) | | (远程)瑞尔 DW | 9000 | 数据源(只读),PAC 主动连 | 🔴 PII(只读) |
**NOT 部署在 PAC 这边**: **NOT 部署在 PAC 这边**:
...@@ -78,10 +78,10 @@ cp apps/pac-service/.env.example apps/pac-service/.env ...@@ -78,10 +78,10 @@ cp apps/pac-service/.env.example apps/pac-service/.env
```ini ```ini
# ─── 基础 ─── # ─── 基础 ───
NODE_ENV=production NODE_ENV=production
PORT=3001 PORT=3101
LOG_LEVEL=info LOG_LEVEL=info
DATABASE_URL=postgresql://pac:<pwd>@localhost:5432/pac?schema=public DATABASE_URL=postgresql://pac:<pwd>@localhost:5532/pac?schema=public
REDIS_URL=redis://localhost:6379 REDIS_URL=redis://localhost:6479
JWT_SECRET=<openssl rand -hex 32> JWT_SECRET=<openssl rand -hex 32>
JWT_REFRESH_SECRET=<openssl rand -hex 32> JWT_REFRESH_SECRET=<openssl rand -hex 32>
CORS_ORIGINS=https://<your-pac-web-domain> CORS_ORIGINS=https://<your-pac-web-domain>
...@@ -108,11 +108,11 @@ PAC_LAG_ERROR_HOURS=48 # > 48h 红色 ERROR ...@@ -108,11 +108,11 @@ PAC_LAG_ERROR_HOURS=48 # > 48h 红色 ERROR
### 2.3 起 Postgres + Redis ### 2.3 起 Postgres + Redis
```bash ```bash
docker run -d --name pac-postgres -p 5432:5432 \ docker run -d --name pac-postgres -p 5532:5432 \
-e POSTGRES_USER=pac -e POSTGRES_PASSWORD=<pwd> -e POSTGRES_DB=pac \ -e POSTGRES_USER=pac -e POSTGRES_PASSWORD=<pwd> -e POSTGRES_DB=pac \
-v pac-pg-data:/var/lib/postgresql/data postgres:15 -v pac-pg-data:/var/lib/postgresql/data postgres:15
docker run -d --name pac-redis -p 6379:6379 \ docker run -d --name pac-redis -p 6479:6379 \
-v pac-redis-data:/data redis:7-alpine -v pac-redis-data:/data redis:7-alpine
``` ```
......
...@@ -809,7 +809,7 @@ PAC 服务用 NestJS + Swagger 自动生成 API 参考。**接入方拿到最完 ...@@ -809,7 +809,7 @@ PAC 服务用 NestJS + Swagger 自动生成 API 参考。**接入方拿到最完
| **离线 Redoc HTML** | 见附件 `docs/api/pac-redoc-v0.html` | 接入方拿到对接文档时一并附带,离线可查 | | **离线 Redoc HTML** | 见附件 `docs/api/pac-redoc-v0.html` | 接入方拿到对接文档时一并附带,离线可查 |
⚠️ v0 阶段 PAC 服务尚未公网部署;接入方: ⚠️ v0 阶段 PAC 服务尚未公网部署;接入方:
- 本地启动 PAC 服务(参见项目 README)→ 访问 `http://localhost:3001/api/docs` - 本地启动 PAC 服务(参见项目 README)→ 访问 `http://localhost:3101/api/docs`
- 或看附件 Redoc HTML(对接文档发出时一同发) - 或看附件 Redoc HTML(对接文档发出时一同发)
## 5.3 关键业务流(序列图) ## 5.3 关键业务流(序列图)
......
...@@ -195,8 +195,8 @@ recall-platform/ ...@@ -195,8 +195,8 @@ recall-platform/
1. pnpm install 无报错 1. pnpm install 无报错
2. docker compose up 能启动所有服务 2. docker compose up 能启动所有服务
3. pnpm dev 能并行启动前后端 3. pnpm dev 能并行启动前后端
4. 访问 http://localhost:3001/api/docs 能看到 Scalar API 文档界面 4. 访问 http://localhost:3101/api/docs 能看到 Scalar API 文档界面
5. 访问 http://localhost:3000 能看到前端页面骨架 5. 访问 http://localhost:3100 能看到前端页面骨架
6. Prisma migrate 能成功创建所有表 6. Prisma migrate 能成功创建所有表
7. TypeScript 类型检查全项目无报错 7. TypeScript 类型检查全项目无报错
8. POST /recall/v1/auth/token 能成功换票并返回 recall_token + code 8. POST /recall/v1/auth/token 能成功换票并返回 recall_token + code
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment