Compare commits
2 Commits
8652476abc
...
a3d4875bde
| Author | SHA1 | Date | |
|---|---|---|---|
| a3d4875bde | |||
| 2a5fb5f469 |
+2
-2
@@ -2,8 +2,8 @@
|
||||
# 部署目录默认:/opt/secondary-school-grade-archive
|
||||
|
||||
WEB_PORT=23566
|
||||
API_PORT=8000
|
||||
API_TARGET=http://127.0.0.1:8000
|
||||
API_PORT=23568
|
||||
API_TARGET=http://127.0.0.1:23568
|
||||
|
||||
SECRET_KEY=请替换为随机字符串
|
||||
POSTGRES_USER=gradeapp
|
||||
|
||||
@@ -46,13 +46,13 @@ cd backend
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate # Windows: venv\Scripts\activate
|
||||
pip install -r requirements.txt
|
||||
uvicorn app.main:app --reload --port 8000
|
||||
uvicorn app.main:app --reload --port 23568
|
||||
|
||||
cd frontend
|
||||
npm install && npm run dev
|
||||
```
|
||||
|
||||
开发前端:http://localhost:5173(代理 `/api` 到 8000)
|
||||
开发前端:http://localhost:5173(代理 `/api` 到 23568)
|
||||
|
||||
生产网关本地模拟:
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ DATABASE_URL=postgresql://gradeapp:postgres@127.0.0.1:5432/student_archive
|
||||
SECRET_KEY=dev-secret-key-change-in-production
|
||||
CORS_ORIGINS=http://localhost:5173,http://localhost:23566
|
||||
UPLOAD_DIR=uploads
|
||||
API_PORT=8000
|
||||
API_PORT=23568
|
||||
OLLAMA_BASE_URL=http://127.0.0.1:11434
|
||||
OLLAMA_MODEL=qwen2.5:7b
|
||||
FLUCTUATION_THRESHOLD=0.08
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ set -euo pipefail
|
||||
REPO_URL="${REPO_URL:-https://git.bz121.com/dekun/secondary-school-grade-archive.git}"
|
||||
INSTALL_DIR="${INSTALL_DIR:-/opt/secondary-school-grade-archive}"
|
||||
WEB_PORT="${WEB_PORT:-23566}"
|
||||
API_PORT="${API_PORT:-8000}"
|
||||
API_PORT="${API_PORT:-23568}"
|
||||
BRANCH="${BRANCH:-main}"
|
||||
NODE_MAJOR="${NODE_MAJOR:-20}"
|
||||
PIP_MIRROR="${PIP_MIRROR:-https://pypi.tuna.tsinghua.edu.cn/simple}"
|
||||
|
||||
@@ -27,7 +27,7 @@ function loadEnv() {
|
||||
|
||||
const env = loadEnv()
|
||||
const webPort = env.WEB_PORT || '23566'
|
||||
const apiPort = env.API_PORT || '8000'
|
||||
const apiPort = env.API_PORT || '23568'
|
||||
const venvPython = path.join(root, 'backend', 'venv', 'bin', 'python')
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -9,7 +9,7 @@ if (fs.existsSync(envPath)) {
|
||||
}
|
||||
|
||||
const PORT = Number(process.env.WEB_PORT || 23566)
|
||||
const API_TARGET = process.env.API_TARGET || 'http://127.0.0.1:8000'
|
||||
const API_TARGET = process.env.API_TARGET || 'http://127.0.0.1:23568'
|
||||
const STATIC_ROOT = path.join(__dirname, '../../frontend/dist')
|
||||
|
||||
const app = express()
|
||||
|
||||
+4
-3
@@ -13,14 +13,14 @@
|
||||
| 系统 | Ubuntu 20.04 / 22.04 / 24.04 |
|
||||
| 用户 | **root** |
|
||||
| 目录 | `/opt/secondary-school-grade-archive` |
|
||||
| 端口 | **23566**(Web + API 统一入口) |
|
||||
| 端口 | **23566** 对外 Web;**23568** 内部 API(仅本机) |
|
||||
| 反向代理 | **不包含**,请自行配置 |
|
||||
|
||||
### 架构
|
||||
|
||||
```
|
||||
浏览器 → :23566 (PM2: grade-web, Express 静态 + /api 反代)
|
||||
└──→ 127.0.0.1:8000 (PM2: grade-api, Uvicorn)
|
||||
└──→ 127.0.0.1:23568 (PM2: grade-api, Uvicorn)
|
||||
└──→ PostgreSQL (本机)
|
||||
└──→ uploads/
|
||||
└──→ Ollama (本机可选, :11434)
|
||||
@@ -72,7 +72,8 @@ bash deploy/install.sh
|
||||
| 变量 | 默认 | 说明 |
|
||||
|------|------|------|
|
||||
| `WEB_PORT` | 23566 | 对外 Web 端口 |
|
||||
| `API_PORT` | 8000 | 内部 API 端口 |
|
||||
| `API_PORT` | 23568 | 内部 API 端口(仅本机,勿与 8000 等常用端口冲突) |
|
||||
| `API_TARGET` | `http://127.0.0.1:23568` | Web 网关转发目标 |
|
||||
| `DATABASE_URL` | 自动生成 | PostgreSQL 连接 |
|
||||
| `SECRET_KEY` | 自动生成 | JWT 密钥 |
|
||||
| `UPLOAD_DIR` | `.../uploads` | 错题图片目录 |
|
||||
|
||||
@@ -7,7 +7,7 @@ export default defineConfig({
|
||||
port: 5173,
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8000',
|
||||
target: 'http://localhost:23568',
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user