Skip to content

Commit 9c77701

Browse files
ModerRASclaude
andcommitted
从 test/paddle-inference-linux 分支恢复缺失的 Linux 部署文件
- 添加 Linux 部署文档 (Docs/LINUX_DEPLOYMENT.md) - 添加 PaddleOCR Linux 兼容性测试 - 添加 Linux 运行和部署脚本 - 更新项目文件支持条件编译和跨平台运行时包 - 更新 README.md 添加 Linux 部署指南 这些文件之前被错误地提交到了已关闭的 test/paddle-inference-linux 分支, 现在恢复到当前的 feature/microsoft-extensions-ai-poc 分支。 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 13cb19d commit 9c77701

File tree

7 files changed

+700
-4
lines changed

7 files changed

+700
-4
lines changed

Docs/LINUX_DEPLOYMENT.md

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
# Linux 部署指南
2+
3+
## 概述
4+
5+
TelegramSearchBot 现在支持 Linux 平台部署。本指南说明了在 Linux 系统上部署和运行 TelegramSearchBot 的要求。
6+
7+
## 系统要求
8+
9+
### 操作系统
10+
- Ubuntu 20.04+ 或 Debian 11+
11+
- 其他 Linux 发行版(可能需要调整依赖包名称)
12+
13+
### .NET 运行时
14+
- .NET 9.0 运行时或 SDK
15+
16+
### 系统依赖包
17+
18+
```bash
19+
# 更新包管理器
20+
sudo apt update
21+
22+
# 安装基础依赖
23+
sudo apt install -y libgomp1 libdnnl2 intel-mkl-full libomp-dev
24+
```
25+
26+
## 项目配置
27+
28+
### 条件编译支持
29+
30+
项目已配置条件编译,根据目标平台自动选择合适的运行时包:
31+
32+
```xml
33+
<!-- Windows 运行时包 -->
34+
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.11.0.20250507"
35+
Condition="'$(RuntimeIdentifier)' == 'win-x64' OR '$(RuntimeIdentifier)' == ''" />
36+
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="3.1.0.54"
37+
Condition="'$(RuntimeIdentifier)' == 'win-x64' OR '$(RuntimeIdentifier)' == ''" />
38+
39+
<!-- Linux 运行时包 -->
40+
<PackageReference Include="OpenCvSharp4.runtime.linux-x64" Version="4.10.0.20240717"
41+
Condition="'$(RuntimeIdentifier)' == 'linux-x64'" />
42+
<PackageReference Include="Sdcb.PaddleInference.runtime.linux-x64.mkl" Version="3.1.0.54"
43+
Condition="'$(RuntimeIdentifier)' == 'linux-x64'" />
44+
```
45+
46+
## 编译和发布
47+
48+
### 编译项目
49+
50+
```bash
51+
# 恢复依赖
52+
dotnet restore TelegramSearchBot.sln
53+
54+
# 编译解决方案
55+
dotnet build TelegramSearchBot.sln --configuration Release
56+
57+
# 运行测试
58+
dotnet test
59+
```
60+
61+
### 发布 Linux 版本
62+
63+
```bash
64+
# 发布 Linux 独立版本
65+
dotnet publish TelegramSearchBot/TelegramSearchBot.csproj \
66+
--configuration Release \
67+
--runtime linux-x64 \
68+
--self-contained true \
69+
--output ./publish/linux-x64
70+
```
71+
72+
## 运行应用程序
73+
74+
### 使用提供的运行脚本
75+
76+
```bash
77+
# 使用提供的 Linux 运行脚本
78+
./run_linux.sh
79+
```
80+
81+
### 手动设置环境变量
82+
83+
```bash
84+
# 设置库路径
85+
export LD_LIBRARY_PATH=/path/to/TelegramSearchBot/.nuget/packages/sdcb.paddleinference.runtime.linux-x64.mkl/3.1.0.54/runtimes/linux-x64/native:$LD_LIBRARY_PATH
86+
87+
# 运行应用程序
88+
cd TelegramSearchBot
89+
dotnet run
90+
```
91+
92+
### 作为系统服务运行
93+
94+
创建 systemd 服务文件 `/etc/systemd/system/telegramsearchbot.service`
95+
96+
```ini
97+
[Unit]
98+
Description=TelegramSearchBot
99+
After=network.target
100+
101+
[Service]
102+
Type=simple
103+
User=telegrambot
104+
WorkingDirectory=/opt/TelegramSearchBot
105+
ExecStart=/opt/TelegramSearchBot/run_linux.sh
106+
Restart=always
107+
RestartSec=10
108+
Environment=LD_LIBRARY_PATH=/opt/TelegramSearchBot/.nuget/packages/sdcb.paddleinference.runtime.linux-x64.mkl/3.1.0.54/runtimes/linux-x64/native
109+
110+
[Install]
111+
WantedBy=multi-user.target
112+
```
113+
114+
启用和启动服务:
115+
116+
```bash
117+
sudo systemctl daemon-reload
118+
sudo systemctl enable telegramsearchbot
119+
sudo systemctl start telegramsearchbot
120+
```
121+
122+
## 故障排除
123+
124+
### 常见问题
125+
126+
1. **库加载失败**
127+
```
128+
Unable to load shared library 'paddle_inference_c'
129+
```
130+
131+
解决方案:
132+
- 确保已安装所有系统依赖包
133+
- 检查 LD_LIBRARY_PATH 环境变量设置
134+
- 验证 PaddleInference Linux 运行时包是否已安装
135+
136+
2. **权限问题**
137+
```
138+
Permission denied
139+
```
140+
141+
解决方案:
142+
- 确保运行脚本有执行权限
143+
- 检查文件和目录权限
144+
145+
3. **模型文件缺失**
146+
```
147+
Model file not found
148+
```
149+
150+
解决方案:
151+
- 确保模型文件已复制到输出目录
152+
- 检查配置文件中的模型路径
153+
154+
### 日志和调试
155+
156+
启用详细日志:
157+
158+
```bash
159+
# 设置日志级别
160+
export Logging__LogLevel__Default=Debug
161+
162+
# 运行应用程序
163+
./run_linux.sh
164+
```
165+
166+
## 性能优化
167+
168+
### CPU 优化
169+
- 使用 MKL 数学库(已默认配置)
170+
- 考虑使用 CPU 亲和性设置
171+
172+
### 内存优化
173+
- 调整 GC 压力设置
174+
- 配置适当的缓存大小
175+
176+
### 存储优化
177+
- 使用 SSD 存储
178+
- 配置适当的数据库连接池
179+
180+
## 安全考虑
181+
182+
### 文件权限
183+
- 确保配置文件权限适当
184+
- 限制对敏感数据的访问
185+
186+
### 网络安全
187+
- 使用防火墙规则
188+
- 配置适当的 TLS 设置
189+
190+
### 更新和维护
191+
- 定期更新依赖包
192+
- 监控安全公告
193+
194+
## 支持的平台
195+
196+
- ✅ Ubuntu 20.04 LTS
197+
- ✅ Ubuntu 22.04 LTS
198+
- ✅ Debian 11 (Bullseye)
199+
- ✅ Debian 12 (Bookworm)
200+
- 🔄 其他 Linux 发行版(可能需要调整)
201+
202+
## 联系支持
203+
204+
如果遇到问题,请检查:
205+
1. 本指南的故障排除部分
206+
2. 项目 GitHub Issues
207+
3. 相关依赖库的文档

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,69 @@
2727

2828
## 安装与配置
2929

30-
### 快速开始
30+
### 支持平台
31+
-**Windows** - 原生支持,推荐使用 ClickOnce 安装包
32+
-**Linux** - 完全支持,需要手动安装依赖和编译
33+
34+
### Linux 系统要求
35+
36+
#### 操作系统
37+
- Ubuntu 20.04+ 或 Debian 11+
38+
- 其他 Linux 发行版(可能需要调整依赖包名称)
39+
40+
#### .NET 运行时
41+
- .NET 9.0 运行时或 SDK
42+
43+
#### 系统依赖包
44+
```bash
45+
# 更新包管理器
46+
sudo apt update
47+
48+
# 安装基础依赖
49+
sudo apt install -y libgomp1 libdnnl2 intel-mkl-full libomp-dev
50+
```
51+
52+
#### 快速开始(Linux)
53+
1. 克隆仓库
54+
```bash
55+
git clone https://github.com/ModerRAS/TelegramSearchBot.git
56+
cd TelegramSearchBot
57+
```
58+
59+
2. 安装依赖
60+
```bash
61+
# 安装系统依赖
62+
sudo apt install -y libgomp1 libdnnl2 intel-mkl-full libomp-dev
63+
64+
# 恢复 .NET 依赖
65+
dotnet restore TelegramSearchBot.sln
66+
```
67+
68+
3. 构建项目
69+
```bash
70+
dotnet build TelegramSearchBot.sln --configuration Release
71+
```
72+
73+
4. 运行验证
74+
```bash
75+
./scripts/verify_linux_deployment.sh
76+
```
77+
78+
5. 运行测试
79+
```bash
80+
./scripts/run_paddle_tests.sh
81+
```
82+
83+
6. 配置并运行
84+
```bash
85+
# 首次运行生成配置文件
86+
./scripts/run_linux.sh
87+
88+
# 编辑配置文件
89+
nano ~/.config/TelegramSearchBot/Config.json
90+
```
91+
92+
### Windows 快速开始
3193
1. 下载[最新版本](https://clickonce.miaostay.com/TelegramSearchBot/Publish.html)
3294
2. 首次运行会自动生成配置目录
3395
3. 编辑`AppData/Local/TelegramSearchBot/Config.json`:

0 commit comments

Comments
 (0)