Files
hertz_django/后端部署教程(开发人员用).md
2025-12-13 16:13:14 +08:00

125 lines
2.5 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

# 后端部署教程
## 一、**环境要求**
- `Python 3.10+`(建议 3.12.3
- 操作系统Windows
- redisredis版本建议用5.0.10(默认地址 `redis://127.0.0.1:6379`
## 二、 获取机器码并激活
### 1获取机器码
```python
python get_machine_code.py
```
运行后会获得一个机器码例如HERTZ_STUDIO_XXXXXXXXXXXXXXXX
将机器码发给相关技术人员进行激活!
## 三、初始化配置
### 1双击运行init_backend.bat
注:此操作会自动创建环境并下载依赖以及完成数据集迁移
## 四、配置Django
### 1将下载的app注册到django项目中
在根目录下面的hertz_server_django文件夹下面的setting文件如下图中注册app
如下图我用到了notice、ai、wiki等模块
![app注册](docs/img/img_1.png)
### 2注册app后配置路由
在根目录下面的hertz_server_django文件夹下面的urls.py文件如下图中配置路由
配置路由参考例如我要配置名为xxx的路由
```python
path('api/xxx/', include('hertz_studio_django_xxx.urls')),
```
如下图我配置了notice、ai、wiki等路由
![路由配置](docs/img/img_2.png)
## **五、启动服务**
- 通过python脚本启动支持端口参数
```python
python start_server.py --port 8000
```
- 通过bat脚本启动快捷
双击 start_server.bat
## 六、默认账号
- 超级管理员:
- 用户名:`hertz`
- 密码:`hertz`
- 普通用户
- 用户名:`demo`
- 密码:`123456`
## **七、问题排查**
### 1`daphne` 或 `watchdog` 未安装:
运行:`pip install daphne watchdog -i https://pypi.tuna.tsinghua.edu.cn/simple``start_server.py:1235-1248` 有依赖检查)。
### 2Redis 未运行:
安装并启动 Redis或调整 `REDIS_URL` 指向可用实例。
### 3视频检测结果展示不了
需配置ffmpeg环境参考文章https://blog.csdn.net/csdn_yudong/article/details/129182648
ffmpeg压缩包在根目录下面的static目录下如下图。
![ffmpeg配置](docs/img/img_3.png)
## **八、项目结构**
- 核心配置:`hertz_server_django/settings.py`、`hertz_server_django/urls.py`
- 启动脚本:`start_server.py`
- 依赖清单:`requirements.txt`
- 静态资源:`static/`,媒体资源:`media/`
## 九、**快速启动**
- 安装依赖:
pip install -r requirements.txt
pip install -r hertz.txt -i https://hertz:hertz@hzpypi.hzsystems.cn/simple/
- 启动服务:`python start_server.py --port 8000`