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_URL=postgresql://pac:pac@localhost:5432/pac?schema=public
DATABASE_URL=postgresql://pac:pac@localhost:5532/pac?schema=public
# --- Redis ---
REDIS_URL=redis://localhost:6379
REDIS_URL=redis://localhost:6479
# --- JWT ---
JWT_SECRET=replace-with-strong-random-secret-min-32-chars
......@@ -18,12 +18,12 @@ AI_GATEWAY_API_KEY=
# --- Service ---
NODE_ENV=development
PORT=3001
PORT=3101
LOG_LEVEL=info
CORS_ORIGINS=http://localhost:3000
CORS_ORIGINS=http://localhost:3100
# --- One-time code ---
EXCHANGE_CODE_TTL_SECONDS=60
# --- 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
pnpm dev
```
- Backend: http://localhost:3001
- API reference: http://localhost:3001/api/docs (Scalar)
- OpenAPI JSON: http://localhost:3001/api/openapi.json
- Frontend: http://localhost:3000
- Backend: http://localhost:3101
- API reference: http://localhost:3101/api/docs (Scalar)
- OpenAPI JSON: http://localhost:3101/api/openapi.json
- Frontend: http://localhost:3100
## Smoke test the auth flow
```bash
# 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' \
-d '{
"appId": "demo-app",
......@@ -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
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' \
-d '{ "code": "<paste code from step 1>" }'
# 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>"
# 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' \
-d '{}' # mock-pull emits ~10 facts → patient_fact_events filled in
```
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
......
......@@ -21,21 +21,21 @@
# production: production ⚠️ 必须设 production,关掉一些开发兜底
NODE_ENV=development
PORT=3001
PORT=3101
# local: debug | staging+prod: info
LOG_LEVEL=info
# ─── 数据库 / 缓存 ────────────────────────────────────────────────────
# local: postgresql://pac:pac@localhost:5432/pac?schema=public
# staging: postgresql://pac:<staging-pwd>@<staging-pg-host>:5432/pac?schema=public
# production: postgresql://pac:<prod-pwd>@<prod-pg-host>:5432/pac?schema=public
DATABASE_URL=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>:5532/pac?schema=public
# production: postgresql://pac:<prod-pwd>@<prod-pg-host>:5532/pac?schema=public
DATABASE_URL=postgresql://pac:pac@localhost:5532/pac?schema=public
# local: redis://localhost:6379
# staging+prod: redis://<host>:6379 (BullMQ 队列用,丢了会丢未消费的 plan-asset-generate 任务)
REDIS_URL=redis://localhost:6379
# local: redis://localhost:6479
# staging+prod: redis://<host>:6479 (BullMQ 队列用,丢了会丢未消费的 plan-asset-generate 任务)
REDIS_URL=redis://localhost:6479
# ─── JWT(per-env 必须不同强随机)────────────────────────────────────
......@@ -67,10 +67,10 @@ AI_REQUEST_TIMEOUT_SEC=60
# ─── CORS / iframe ───────────────────────────────────────────────────
# local: http://localhost:3000
# local: http://localhost:3100
# staging: https://pac-staging.<your-domain>
# production: https://pac.<your-domain> (多个用逗号)
CORS_ORIGINS=http://localhost:3000
CORS_ORIGINS=http://localhost:3100
# iframe 一次性 code TTL(默认 60s)
EXCHANGE_CODE_TTL_SECONDS=60
......
......@@ -35,7 +35,7 @@ function parseArgs(argv: string[]): CliArgs {
cmd: (argv[0] as CliArgs['cmd']) ?? 'help',
host: 'mock-host',
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)) {
if (a.startsWith('--host=')) out.host = a.slice('--host='.length);
......@@ -59,7 +59,7 @@ Commands:
Options:
--host=<name> host name(default mock-host)
--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 = {
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
```bash
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_PASSWORD=<强密码> \
-e POSTGRES_DB=pac \
......@@ -42,7 +42,7 @@ sudo docker run -d --name pac-postgres --restart unless-stopped \
postgres:15
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 \
redis:7-alpine
```
......@@ -97,8 +97,8 @@ sudo -u pac bash /opt/pac/deploy/deploy.sh production
### 6. 验证
```bash
curl http://localhost:3001/health # 应返 {"status":"ok"} 或类似
curl http://localhost:3000 # Next.js 首页 HTML
curl http://localhost:3101/health # 应返 {"status":"ok"} 或类似
curl http://localhost:3100 # Next.js 首页 HTML
journalctl -u pac-service -n 50 -f # 看日志
journalctl -u pac-web -n 50 -f
```
......
......@@ -103,5 +103,5 @@ echo "════════════════════════
echo "✓ 部署完成 — $AFTER_HEAD ($(date '+%F %T'))"
echo "═══════════════════════════════════════════════════════════"
echo "验证:"
echo " curl http://localhost:3001/health"
echo " curl http://localhost:3101/health"
echo " 打开 https://<your-domain>/plans"
......@@ -52,7 +52,7 @@ services:
condition: service_completed_successfully
environment:
NODE_ENV: production
PORT: 3001
PORT: 3101
DATABASE_URL: ${DATABASE_URL}
REDIS_URL: ${REDIS_URL}
JWT_SECRET: ${JWT_SECRET}
......@@ -64,7 +64,7 @@ services:
CORS_ORIGINS: ${CORS_ORIGINS}
EXCHANGE_CODE_TTL_SECONDS: ${EXCHANGE_CODE_TTL_SECONDS:-60}
ports:
- "3001:3001"
- "3101:3101"
pac-web:
build:
......@@ -77,8 +77,9 @@ services:
environment:
NODE_ENV: production
NEXT_PUBLIC_API_BASE_URL: ${NEXT_PUBLIC_API_BASE_URL}
PORT: 3100
ports:
- "3000:3000"
- "3100:3100"
volumes:
postgres_data:
......
......@@ -8,7 +8,7 @@ services:
POSTGRES_PASSWORD: pac
POSTGRES_DB: pac
ports:
- "5432:5432"
- "5532:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
......@@ -47,7 +47,7 @@ services:
container_name: pac-redis
restart: unless-stopped
ports:
- "6379:6379"
- "6479:6379"
volumes:
- redis_data:/data
healthcheck:
......@@ -70,7 +70,7 @@ services:
condition: service_healthy
environment:
NODE_ENV: development
PORT: 3001
PORT: 3101
DATABASE_URL: postgresql://pac:pac@postgres:5432/pac?schema=public
REDIS_URL: redis://redis:6379
JWT_SECRET: dev-secret-change-me-in-production-min-32-chars
......@@ -79,10 +79,10 @@ services:
JWT_REFRESH_EXPIRES_IN: 7d
AI_GATEWAY_URL: https://ai-gateway.example.com
AI_GATEWAY_API_KEY: dev-placeholder
CORS_ORIGINS: http://localhost:3000
CORS_ORIGINS: http://localhost:3100
EXCHANGE_CODE_TTL_SECONDS: 60
ports:
- "3001:3001"
- "3101:3101"
volumes:
- ./apps/pac-service:/app/apps/pac-service
- ./packages:/app/packages
......@@ -100,9 +100,10 @@ services:
- pac-service
environment:
NODE_ENV: development
NEXT_PUBLIC_API_BASE_URL: http://localhost:3001
NEXT_PUBLIC_API_BASE_URL: http://localhost:3101
PORT: 3100
ports:
- "3000:3000"
- "3100:3100"
volumes:
- ./apps/pac-web:/app/apps/pac-web
- ./packages:/app/packages
......
......@@ -14,7 +14,7 @@
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Postgres 15 │ │ Redis 7 │ │ pac-web │ │
│ │ :5432 │ │ :6379 │ │ :3000 │ Next.js │
│ │ :5532 │ │ :6479 │ │ :3100 │ Next.js │
│ │ pac DB │ │ BullMQ / │ │ │ prod build│
│ │ │ │ session │ │ │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
......@@ -23,7 +23,7 @@
│ │ │
│ ┌───────▼────────┐ │
│ │ pac-service │ NestJS │
│ │ :3001 │ - HTTP API │
│ │ :3101 │ - HTTP API │
│ │ │ - BullMQ Worker │
│ │ │ - Cron(增量同步/监控) │
│ └───────┬────────┘ │
......@@ -41,10 +41,10 @@
| 组件 | 端口 | 用途 | 数据敏感度 |
|---|---|---|---|
| Postgres 15 | 5432 | PAC 主数据(patients / facts / personas / plans / sync_logs) | 🔴 PII |
| Redis 7 | 6379 | BullMQ 队列 + 会话 | 🟡 session token |
| pac-service | 3001 | API + Cron + Worker | — |
| pac-web | 3000 | 前端(Next.js) | — |
| Postgres 15 | 5532 | PAC 主数据(patients / facts / personas / plans / sync_logs) | 🔴 PII |
| Redis 7 | 6479 | BullMQ 队列 + 会话 | 🟡 session token |
| pac-service | 3101 | API + Cron + Worker | — |
| pac-web | 3100 | 前端(Next.js) | — |
| (远程)瑞尔 DW | 9000 | 数据源(只读),PAC 主动连 | 🔴 PII(只读) |
**NOT 部署在 PAC 这边**:
......@@ -78,10 +78,10 @@ cp apps/pac-service/.env.example apps/pac-service/.env
```ini
# ─── 基础 ───
NODE_ENV=production
PORT=3001
PORT=3101
LOG_LEVEL=info
DATABASE_URL=postgresql://pac:<pwd>@localhost:5432/pac?schema=public
REDIS_URL=redis://localhost:6379
DATABASE_URL=postgresql://pac:<pwd>@localhost:5532/pac?schema=public
REDIS_URL=redis://localhost:6479
JWT_SECRET=<openssl rand -hex 32>
JWT_REFRESH_SECRET=<openssl rand -hex 32>
CORS_ORIGINS=https://<your-pac-web-domain>
......@@ -108,11 +108,11 @@ PAC_LAG_ERROR_HOURS=48 # > 48h 红色 ERROR
### 2.3 起 Postgres + Redis
```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 \
-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
```
......
......@@ -809,7 +809,7 @@ PAC 服务用 NestJS + Swagger 自动生成 API 参考。**接入方拿到最完
| **离线 Redoc HTML** | 见附件 `docs/api/pac-redoc-v0.html` | 接入方拿到对接文档时一并附带,离线可查 |
⚠️ v0 阶段 PAC 服务尚未公网部署;接入方:
- 本地启动 PAC 服务(参见项目 README)→ 访问 `http://localhost:3001/api/docs`
- 本地启动 PAC 服务(参见项目 README)→ 访问 `http://localhost:3101/api/docs`
- 或看附件 Redoc HTML(对接文档发出时一同发)
## 5.3 关键业务流(序列图)
......
......@@ -195,8 +195,8 @@ recall-platform/
1. pnpm install 无报错
2. docker compose up 能启动所有服务
3. pnpm dev 能并行启动前后端
4. 访问 http://localhost:3001/api/docs 能看到 Scalar API 文档界面
5. 访问 http://localhost:3000 能看到前端页面骨架
4. 访问 http://localhost:3101/api/docs 能看到 Scalar API 文档界面
5. 访问 http://localhost:3100 能看到前端页面骨架
6. Prisma migrate 能成功创建所有表
7. TypeScript 类型检查全项目无报错
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