Merge branch 'main' of https://git.hanxiaokj.cn/zw/iOSAI
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- 并发提速:_add_device 异步化(受控并发)
|
- 并发提速:_add_device 异步化(受控并发)
|
||||||
- iproxy 守护:本地端口 + /status 探活,不通则自愈重启;连续失败达阈值才移除
|
- iproxy 守护:本地端口 + /status 探活,不通则自愈重启;连续失败达阈值才移除
|
||||||
"""
|
"""
|
||||||
|
import datetime
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
@@ -310,6 +311,7 @@ class DeviceInfo:
|
|||||||
FAIL_THRESHOLD = int(os.getenv("IPROXY_FAIL_THRESHOLD", "3")) # 连续失败阈值(可用环境变量调)
|
FAIL_THRESHOLD = int(os.getenv("IPROXY_FAIL_THRESHOLD", "3")) # 连续失败阈值(可用环境变量调)
|
||||||
INTERVAL_SEC = int(os.getenv("IPROXY_CHECK_INTERVAL", "10")) # 巡检间隔
|
INTERVAL_SEC = int(os.getenv("IPROXY_CHECK_INTERVAL", "10")) # 巡检间隔
|
||||||
|
|
||||||
|
try:
|
||||||
while True:
|
while True:
|
||||||
snapshot = list(self._models.items()) # [(deviceId, DeviceModel), ...]
|
snapshot = list(self._models.items()) # [(deviceId, DeviceModel), ...]
|
||||||
for device_id, model in snapshot:
|
for device_id, model in snapshot:
|
||||||
@@ -411,6 +413,9 @@ class DeviceInfo:
|
|||||||
print(f"[iproxy-check] 单设备检查异常: {e}")
|
print(f"[iproxy-check] 单设备检查异常: {e}")
|
||||||
|
|
||||||
time.sleep(INTERVAL_SEC)
|
time.sleep(INTERVAL_SEC)
|
||||||
|
except Exception as e:
|
||||||
|
print("检查iproxy状态遇到错误:",e)
|
||||||
|
LogManager.error("检查iproxy状态遇到错误:",e)
|
||||||
|
|
||||||
def listen(self):
|
def listen(self):
|
||||||
LogManager.method_info("进入主循环", "listen", udid="system")
|
LogManager.method_info("进入主循环", "listen", udid="system")
|
||||||
@@ -435,6 +440,7 @@ class DeviceInfo:
|
|||||||
|
|
||||||
for udid in online - known:
|
for udid in online - known:
|
||||||
if (now - self._first_seen.get(udid, now)) >= self.ADD_STABLE_SEC:
|
if (now - self._first_seen.get(udid, now)) >= self.ADD_STABLE_SEC:
|
||||||
|
print(datetime.datetime.now().strftime("%H:%M:%S"))
|
||||||
print(f"[Add] 检测到新设备: {udid}")
|
print(f"[Add] 检测到新设备: {udid}")
|
||||||
try:
|
try:
|
||||||
self._add_device(udid) # ← 并发包装器
|
self._add_device(udid) # ← 并发包装器
|
||||||
@@ -561,6 +567,7 @@ class DeviceInfo:
|
|||||||
|
|
||||||
print(f"[Manager] 准备发送设备数据到前端 {udid}")
|
print(f"[Manager] 准备发送设备数据到前端 {udid}")
|
||||||
self._manager_send(model)
|
self._manager_send(model)
|
||||||
|
print(datetime.datetime.now().strftime("%H:%M:%S"))
|
||||||
print(f"[Add] 设备添加成功 {udid}, port={port}, {w}x{h}@{s}")
|
print(f"[Add] 设备添加成功 {udid}, port={port}, {w}x{h}@{s}")
|
||||||
|
|
||||||
def _remove_device(self, udid: str):
|
def _remove_device(self, udid: str):
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user