添加gpio控制/进程健康管理

This commit is contained in:
gqc
2025-12-03 14:12:38 +08:00
parent 7a9d103943
commit 9b02bd9779
6 changed files with 302 additions and 27 deletions
+13
View File
@@ -15,6 +15,8 @@ type PortManager struct {
allocated map[string]int // DeviceUUID 到推理端口的映射
portPool []int // 推理端口池(HTTP
available map[int]bool // 可用端口标记
basePort int
maxPort int
}
func NewPortManager() *PortManager {
@@ -94,3 +96,14 @@ func (pm *PortManager) ReleasePort(deviceUUID string) {
// GlobalPortManager 全局端口管理器
var GlobalPortManager = NewPortManager()
func (pm *PortManager) GetPort(deviceUUID string) (int, error) {
pm.mu.Lock()
defer pm.mu.Unlock()
if port, exists := pm.allocated[deviceUUID]; exists {
return port, nil
}
return 0, fmt.Errorf("device %s has no allocated port", deviceUUID)
}