fix(edge): LOCAL模式下独立连接云端Redis,确保截图处理器可用
CONFIG_SYNC_MODE=LOCAL 时 config_sync 不初始化云端 Redis, 截图处理器改为独立创建 Redis 连接。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
25
main.py
25
main.py
@@ -184,7 +184,30 @@ class EdgeInferenceService:
|
||||
def _init_screenshot_handler(self):
|
||||
"""初始化截图处理器"""
|
||||
try:
|
||||
# 优先从 config_manager 获取已有的云端 Redis 连接
|
||||
cloud_redis = getattr(self._config_manager, '_cloud_redis', None)
|
||||
|
||||
# LOCAL 模式下 config_manager 不初始化云端 Redis,需要独立创建
|
||||
if cloud_redis is None:
|
||||
try:
|
||||
import redis
|
||||
cfg = self._settings.cloud_redis
|
||||
cloud_redis = redis.Redis(
|
||||
host=cfg.host,
|
||||
port=cfg.port,
|
||||
db=cfg.db,
|
||||
password=cfg.password,
|
||||
decode_responses=cfg.decode_responses,
|
||||
socket_connect_timeout=5,
|
||||
socket_timeout=5,
|
||||
retry_on_timeout=True,
|
||||
)
|
||||
cloud_redis.ping()
|
||||
self._logger.info(f"截图处理器独立连接云端 Redis 成功: {cfg.host}:{cfg.port}/{cfg.db}")
|
||||
except Exception as e:
|
||||
self._logger.warning(f"截图处理器无法连接云端 Redis: {e}")
|
||||
cloud_redis = None
|
||||
|
||||
if cloud_redis and self._stream_manager:
|
||||
self._screenshot_handler = ScreenshotHandler(
|
||||
cloud_redis=cloud_redis,
|
||||
@@ -193,7 +216,7 @@ class EdgeInferenceService:
|
||||
self._screenshot_handler.start()
|
||||
self._logger.info("截图处理器初始化成功")
|
||||
else:
|
||||
self._logger.info("截图处理器跳过初始化(云端 Redis 或流管理器不可用)")
|
||||
self._logger.warning("截图处理器跳过初始化(云端 Redis 不可达或流管理器不可用)")
|
||||
except Exception as e:
|
||||
self._logger.error(f"截图处理器初始化失败: {e}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user