Files
AIclinicalresearch/backend/env.example.md
HaHafeng 61cdc97eeb feat(platform): Fix pg-boss queue conflict and add safety standards
Summary:
- Fix pg-boss queue conflict (duplicate key violation on queue_pkey)
- Add global error listener to prevent process crash
- Reduce connection pool from 10 to 4
- Add graceful shutdown handling (SIGTERM/SIGINT)
- Fix researchWorker recursive call bug in catch block
- Make screeningWorker idempotent using upsert

Security Standards (v1.1):
- Prohibit recursive retry in Worker catch blocks
- Prohibit payload bloat (only store fileKey/ID in job.data)
- Require Worker idempotency (upsert + unique constraint)
- Recommend task-specific expireInSeconds settings
- Document graceful shutdown pattern

New Features:
- PKB signed URL endpoint for document preview/download
- pg_bigm installation guide for Docker
- Dockerfile.postgres-with-extensions for pgvector + pg_bigm

Documentation:
- Update Postgres-Only async task processing guide (v1.1)
- Add troubleshooting SQL queries
- Update safety checklist

Tested: Local verification passed
2026-01-23 22:07:26 +08:00

81 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 环境变量配置示例
复制以下内容到 `.env` 文件中:
```bash
# ===========================================
# AI Clinical Research Platform - 环境变量配置
# ===========================================
# ==================== 应用配置 ====================
NODE_ENV=development
PORT=3001
HOST=0.0.0.0
LOG_LEVEL=debug
SERVICE_NAME=aiclinical-backend
# ==================== 数据库配置 ====================
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/ai_clinical
# ==================== 存储配置 ====================
# 存储类型local | oss
STORAGE_TYPE=local
# --- 本地存储配置STORAGE_TYPE=local---
LOCAL_STORAGE_DIR=uploads
LOCAL_STORAGE_URL=http://localhost:3001/uploads
# --- 阿里云OSS配置STORAGE_TYPE=oss---
# OSS_REGION=oss-cn-beijing
# OSS_BUCKET=ai-clinical-data-dev
# OSS_BUCKET_STATIC=ai-clinical-static-dev
# OSS_ACCESS_KEY_ID=your-access-key-id
# OSS_ACCESS_KEY_SECRET=your-access-key-secret
# OSS_INTERNAL=false
# OSS_SIGNED_URL_EXPIRES=3600
# ==================== 安全配置 ====================
JWT_SECRET=your-secret-key-change-in-production
JWT_EXPIRES_IN=7d
CORS_ORIGIN=http://localhost:5173
# ==================== LLM API配置 ====================
DEEPSEEK_API_KEY=
DEEPSEEK_BASE_URL=https://api.deepseek.com
DASHSCOPE_API_KEY=
GEMINI_API_KEY=
# ==================== 文件上传配置 ====================
UPLOAD_MAX_SIZE=31457280
```
## OSS 开发环境配置
如果要测试 OSS`STORAGE_TYPE` 改为 `oss` 并填写以下配置:
```bash
STORAGE_TYPE=oss
OSS_REGION=oss-cn-beijing
OSS_BUCKET=ai-clinical-data-dev
OSS_BUCKET_STATIC=ai-clinical-static-dev
OSS_ACCESS_KEY_ID=LTAI5tBHkL39GjdLfcr77Y3f
OSS_ACCESS_KEY_SECRET=<从安全渠道获取>
OSS_INTERNAL=false
OSS_SIGNED_URL_EXPIRES=3600
```
## OSS 生产环境配置SAE
```bash
STORAGE_TYPE=oss
OSS_REGION=oss-cn-beijing
OSS_BUCKET=ai-clinical-data
OSS_BUCKET_STATIC=ai-clinical-static
OSS_ACCESS_KEY_ID=LTAI5tBHkL39GjdLfcr77Y3f
OSS_ACCESS_KEY_SECRET=<从安全渠道获取>
OSS_INTERNAL=true # 🔴 生产必须用内网
OSS_SIGNED_URL_EXPIRES=3600
```