feat: RESTART 走 NSSM 服务重启 + 失败原因可观测化
- RESTART 命令优先通过 nssm restart 重启主程序服务(假死场景可用),未配置服务名回退环回 HTTP - nssm 输出按 UTF-16 解码并记录日志,权限不足时提示需以服务方式运行 - 环回管理接口 code=3001 时明确报鉴权失败,不再误报不可达 - 新增 nssm.path / main.service.name / log.dir 配置项 - 增加文件日志(RotatingFileHandler 5MB×5),服务方式运行可查日志 - HTTP 调用失败与状态码异常统一 WARNING 记录(原 DEBUG 不可见) - 断线日志区分「网络不通」与「被服务器拒绝(未注册/token 错误)」 - 连接 URL 自动拼接 device.id,消除双处配置不一致 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+6
-1
@@ -98,7 +98,12 @@ class AgentClient:
|
||||
|
||||
def on_error(ws, error):
|
||||
self._connected = False
|
||||
log.warning("网络不通(无法连接管理服务器):%s,将重连", error)
|
||||
# websocket-client 收到服务器关闭帧时会先回调本方法(特征:fin=1 opcode=8),
|
||||
# 这不是网络问题,而是被服务器拒绝(设备未注册 / token 错误)
|
||||
if "opcode=8" in str(error):
|
||||
log.warning("连接被服务器拒绝(设备未注册或 token 错误):%s", error)
|
||||
else:
|
||||
log.warning("网络不通(无法连接管理服务器):%s,将重连", error)
|
||||
# websocket-client 出错后必定回调 on_close,重连由 on_close 统一调度
|
||||
# 此处不重复调度,避免双重重连
|
||||
|
||||
|
||||
Reference in New Issue
Block a user