This commit is contained in:
2026-09-02 18:18:42 +08:00
parent 5e531ffe1e
commit 4fbff0761a
18 changed files with 239 additions and 111 deletions
+30 -29
View File
@@ -6,8 +6,8 @@
当前项目支持三种部署模式:
- **unified**:frontend + unified backend + celery,统一对外部署(当前推荐)
- **gemold-only**:仅部署模具分析后端
- **unified**:frontend + unified backend + moldinsight Celery worker,统一对外部署(当前推荐)
- **moldinsight-only**:仅部署模具分析后端
- **inventory-only**:仅部署进销存后端
项目保持:
@@ -34,10 +34,10 @@
### 按模块附加要求
#### gemold / unified 需要
#### moldinsight / unified 需要
- 服务器上已可访问的 MinIO 或 RustFS 兼容对象存储
- PythonOCC 运行环境
- Celery worker(推荐与 gemold 一起部署)
- Celery worker(推荐与 moldinsight 一起部署)
#### inventory-only 需要
- PostgreSQL
@@ -73,7 +73,7 @@ pip install --upgrade pip
pip install -r requirements.txt
```
> 如果需要 gemold 分析能力,请额外准备 PythonOCC 运行环境。该依赖通常通过 conda 或预构建运行镜像提供,而不是直接由 pip 安装。
> 如果需要 moldinsight 分析能力,请额外准备 PythonOCC 运行环境。该依赖通常通过 conda 或预构建运行镜像提供,而不是直接由 pip 安装。
---
@@ -117,7 +117,7 @@ RUSTFS_SECRET_KEY=minioadmin
```
说明:
- `RUSTFS_*` 仅 **gemold / unified** 模式需要
- `RUSTFS_*` 仅 **moldinsight / unified** 模式需要
- `inventory-only` 可不使用对象存储
- 当前配置读取实现见 [settings.py](../../src/shared/config/settings.py)
@@ -136,7 +136,7 @@ RUSTFS_SECRET_KEY=minioadmin
相关实现参考:
- [init_db.py](../../src/shared/database/init_db.py)
> 当前项目是 **单数据库** 设计,因此 unified / gemold-only / inventory-only 都连接到同一个数据库与同一 migration head。
> 当前项目是 **单数据库** 设计,因此 unified / moldinsight-only / inventory-only 都连接到同一个数据库与同一 migration head。
---
@@ -149,7 +149,7 @@ RUSTFS_SECRET_KEY=minioadmin
- `/` → 前端静态资源与 SPA 路由
- `/api` → unified backend
- `/health` → unified backend
- `/html` → unified backend(内部再提供 gemold 分析产物)
- `/html` → unified backend(内部再提供 moldinsight 分析产物)
如果使用根目录 [docker-compose.yml](../../docker-compose.yml) 的 `frontend` 服务,则该入口已经内置在前端 Nginx 镜像中。
@@ -168,7 +168,7 @@ uvicorn src.entrypoints.inventory:app --host 0.0.0.0 --port 8001
---
## 6.2 gemold-only
## 6.2 moldinsight-only
```bash
source .venv/bin/activate
@@ -179,7 +179,7 @@ uvicorn src.entrypoints.moldinsight:app --host 0.0.0.0 --port 8000
- 单独部署模具分析能力
- 文件上传 / 分析 / 导出 / 批量分析
### gemold Celery worker
### moldinsight Celery worker
建议同时启动 worker:
@@ -188,18 +188,19 @@ source .venv/bin/activate
celery -A src.celery_app.celery_app worker --loglevel=info
```
> gemold 的异步处理链路依赖 Celery + Redis;若只启动 HTTP 服务而不启动 worker,上传分析任务可能无法完整处理。
> moldinsight 的异步处理链路依赖 Celery + Redis;若只启动 HTTP 服务而不启动 worker,上传分析任务可能无法完整处理。
---
## 6.3 unified
当前仓库历史上存在过统一入口,但它更适合作为**过渡参考**,不建议再作为长期标准入口。
`unified` 是当前推荐的默认部署方式,适合 frontend 同域反代到单一 backend 的本地开发、集成环境与统一部署场景。
在正式完成组合层重构前,如需统一部署,可优先使用反向代理或部署编排层统一暴露 gemold 与 inventory;后续会演进为显式 `unified_app.py`。
如需按模块独立部署,则使用 `moldinsight-only` 或 `inventory-only` 入口;它们仍共享同一个仓库、同一个数据库与同一套基础设施。
蓝图参考:
- [archive/BACKEND_MODULARIZATION_BLUEPRINT.md](../archive/BACKEND_MODULARIZATION_BLUEPRINT.md)
当前入口与部署编排见:
- [../../docker-compose.yml](../../docker-compose.yml)
- [../../src/entrypoints/unified.py](../../src/entrypoints/unified.py)
---
@@ -210,7 +211,7 @@ celery -A src.celery_app.celery_app worker --loglevel=info
创建:
```bash
sudo nano /etc/systemd/system/gemold-inventory.service
sudo nano /etc/systemd/system/moldinsight-inventory.service
```
```ini
@@ -236,18 +237,18 @@ WantedBy=multi-user.target
```bash
sudo systemctl daemon-reload
sudo systemctl enable gemold-inventory
sudo systemctl start gemold-inventory
sudo systemctl enable moldinsight-inventory
sudo systemctl start moldinsight-inventory
```
---
## 7.2 gemold-only API 服务
## 7.2 moldinsight-only API 服务
创建:
```bash
sudo nano /etc/systemd/system/gemold-moldinsight.service
sudo nano /etc/systemd/system/moldinsight-moldinsight.service
```
```ini
@@ -271,12 +272,12 @@ WantedBy=multi-user.target
---
## 7.3 gemold Celery worker 服务
## 7.3 moldinsight Celery worker 服务
创建:
```bash
sudo nano /etc/systemd/system/gemold-celery.service
sudo nano /etc/systemd/system/moldinsight-celery.service
```
```ini
@@ -309,7 +310,7 @@ WantedBy=multi-user.target
- `/` 提供前端静态资源与 SPA fallback
- `/api/` 反代后端
- `/health` 反代后端
- `/html/` 反代 gemold
- `/html/` 反代 moldinsight
### 8.1 inventory-only
@@ -328,12 +329,12 @@ server {
}
```
### 8.2 gemold-only
### 8.2 moldinsight-only
```nginx
server {
listen 80;
server_name gemold.example.com;
server_name moldinsight.example.com;
location / {
proxy_pass http://127.0.0.1:8000;
@@ -361,7 +362,7 @@ inventory-only:
curl http://127.0.0.1:8001/health
```
gemold-only:
moldinsight-only:
```bash
curl http://127.0.0.1:8000/health
@@ -374,7 +375,7 @@ curl http://127.0.0.1:8000/health
- `/api/products` 返回数据
- `/api/inventory` 返回数据
#### gemold-only
#### moldinsight-only
- 登录接口可用
- `/api/upload` 可访问
- 上传后 worker 能正常消费任务
@@ -388,9 +389,9 @@ curl http://127.0.0.1:8000/health
因为当前项目已演进为模块化结构,`src.main:app` 更适合作为过渡兼容入口,而不是长期部署标准。应优先围绕 [entrypoints/](../../src/entrypoints/) 部署。
### 2. inventory-only 为什么不需要对象存储?
因为对象存储主要服务于 gemold 分析产物(HTML、导出文件等)。纯 inventory 部署不需要这部分基础设施。
因为对象存储主要服务于 moldinsight 分析产物(HTML、导出文件等)。纯 inventory 部署不需要这部分基础设施。
### 3. gemold-only 为什么建议同时部署 Celery?
### 3. moldinsight-only 为什么建议同时部署 Celery?
因为模具分析任务通常走异步处理链路,仅启动 API 而不启动 worker,会影响上传后的任务处理。
---