fix:优化wsl环境下的边缘设备执行逻辑

This commit is contained in:
Daniel
2026-04-07 02:06:43 +08:00
parent afec0980d4
commit 6b9b9d60b5
7 changed files with 439 additions and 4 deletions

View File

@@ -76,6 +76,34 @@ cd video_worker
bash scripts/start_edge_device_local.sh
```
Windows + WSL 一键边缘设备启动(推荐):
```powershell
cd video_worker
.\scripts\edge_device_wsl.ps1 -Action start
```
常用操作:
```powershell
.\scripts\edge_device_wsl.ps1 -Action status
.\scripts\edge_device_wsl.ps1 -Action restart
.\scripts\edge_device_wsl.ps1 -Action stop
```
多发行版时可指定:
```powershell
.\scripts\edge_device_wsl.ps1 -Action start -Distro Ubuntu-22.04
```
边缘设备停止 / 重启:
```bash
bash scripts/stop_edge_device_local.sh
bash scripts/restart_edge_device_local.sh
```
独立 WS 网关服务(远程推荐):
```bash
@@ -223,6 +251,46 @@ video_worker/
- 查看在线边缘设备
- `WS /ws/edge/{device_id}`edge_dispatch_service
- 边缘设备接入通道
- `POST /devices/{device_id}/command`edge_dispatch_service
- 通过 HTTP 下发设备运维指令(中心自动转 WS
- `GET /commands/{dispatch_id}`edge_dispatch_service
- 查询设备指令执行状态和结果
边缘设备 WS 控制指令(由上游下发到 `edge_device_client.py`
- `generate`: 下发生成任务
- `update_code`: 拉取最新代码(默认执行 `git fetch --all && git checkout <branch> && git pull --ff-only origin <branch>`,可通过 `command` 自定义)
- `restart_service`: 执行边缘本地重启脚本
- `ping`: 心跳探活,设备回 `pong`
HTTP 下发设备指令示例(推荐上游系统使用):
```bash
# 1) 更新边缘设备代码
curl -X POST http://<dispatch-host>:8020/devices/edge-a4000-01/command \
-H "Content-Type: application/json" \
-d '{
"command": "update_code",
"branch": "master"
}'
# 2) 重启边缘设备服务
curl -X POST http://<dispatch-host>:8020/devices/edge-a4000-01/command \
-H "Content-Type: application/json" \
-d '{
"command": "restart_service"
}'
# 3) 设备心跳检查
curl -X POST http://<dispatch-host>:8020/devices/edge-a4000-01/command \
-H "Content-Type: application/json" \
-d '{
"command": "ping"
}'
# 4) 查询指令执行状态(使用上一步返回的 dispatch_id
curl http://<dispatch-host>:8020/commands/<dispatch_id>
```
参数限制: