添加gpio控制/进程健康管理
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user