Skip to content

Commit 91359dc

Browse files
committed
chore: 优化重连 socketio 后没有启用的问题
1 parent 5c7da9f commit 91359dc

File tree

2 files changed

+42
-35
lines changed

2 files changed

+42
-35
lines changed

core/cluster.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,17 @@ async def _(message: Any):
179179

180180
@self.sio.on("connect") # type: ignore
181181
async def _():
182-
logger.tdebug("cluster.connected", id=self.id)
182+
logger.tinfo("cluster.connected", id=self.id)
183+
if not self._enabled:
184+
return
185+
self._enabled = False
186+
logger.tinfo("cluster.reconnect", id=self.id)
187+
await self.enable()
188+
183189

184190
@self.sio.on("disconnect") # type: ignore
185191
async def _():
186-
logger.tdebug("cluster.disconnected", id=self.id)
192+
logger.tinfo("cluster.disconnected", id=self.id)
187193

188194
task_group.start_soon(self.keepalive)
189195

locale/zh_cn.json

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
11
{
2+
"debug.cluster.get_files": "获取节点 [${id}] 文件列表 大小 [${size}] 数量 [${count}] 最后修改日期 [${last_modified}]",
3+
"debug.cluster.refresh_token.schedule": "下一次节点 [${id}] Token 刷新将在 [${next}] 秒后进行",
4+
"debug.web.forward.tls_port": "TLS 端口在 [${port}] 上开启",
5+
"debug.web.uvicorn.port": "Web 服务器监听端口 [${port}]",
6+
"error.cluster.enable": "节点 [${id}] 上线失败 [${err}]",
7+
"error.cluster.enable.timeout": "节点 [${id}] 注册超时",
8+
"error.cluster.exception": "节点 [${id}] 异常:[${msg}]",
9+
"error.cluster.kicked": "节点 [${id}] 被主控踢出下线",
10+
"error.cluster.refresh_token": "刷新节点 [${id}] Token 失败",
11+
"error.cluster.request_cert.error": "节点 [${id}] 申请证书失败",
12+
"error.core.initialize.missing": "当前加载节点数 [${clusters}] 存储数 [${storages}]",
13+
"error.core.initialize.storages": "无法初始化存储",
14+
"error.web.certificates": "没有可用证书",
15+
"error.web.forward.pub_port": "公共端口 [${port}] 错误",
16+
"error.web.tls_listener": "TLS 监听器错误",
17+
"info.cluster.connected": "节点 [${id}] 已连接至主控",
18+
"info.cluster.disable": "节点 [${id}] 下线",
19+
"info.cluster.disconnected": "节点 [${id}] 已断开连接",
20+
"info.cluster.enable": "节点 [${id}] 已上线",
21+
"info.cluster.message": "节点 [${id}] 消息 [${msg}]",
22+
"info.cluster.reconnect": "节点 [${id}] 与主控连接成功,恢复启用状态",
23+
"info.cluster.request_cert": "请求节点 [${id}] 证书",
24+
"info.cluster.retry": "节点 [${id}] 将在 [${time}s] 后尝试重新上线",
25+
"info.cluster.sync.files": "获取文件列表 大小 [${size}] 数量 [${count}] 最后修改日期 [${last_modified}]",
26+
"info.cluster.sync.missing_files": "当前缺失 [${count}] 文件,总计 [${size}]",
27+
"info.cluster.sync.no_files": "没有新文件",
28+
"info.cluster.sync.no_missing_files": "没有缺失文件",
29+
"info.cluster.want_enable": "节点 [${id}] 上线",
30+
"info.core.exit": "已退出",
231
"info.core.initialize": "初始化中...",
3-
"info.core.initialize.version": "API 版本: [${api_version}] Python OpenBMCLAPI 版本 [${version}]",
32+
"info.core.initialize.cluster": "加载节点 [${id}]",
433
"info.core.initialize.platform": "操作平台 [${os} ${arch}] Python 版本 [${python}]",
534
"info.core.initialize.storage": "加载存储 [${name} (${type})]",
6-
"info.core.initialize.cluster": "加载节点 [${id}]",
35+
"info.core.initialize.version": "API 版本: [${api_version}] Python OpenBMCLAPI 版本 [${version}]",
736
"info.core.initialized.storages": "已加载存储: [${count}]",
8-
"info.core.exit": "已退出",
9-
"info.web.forward.pub_port": "公共端口 [${port}]",
10-
"info.cluster.sync.files": "获取文件列表 大小 [${size}] 数量 [${count}] 最后修改日期 [${last_modified}]",
11-
"info.cluster.sync.missing_files": "当前缺失 [${count}] 文件,总计 [${size}]",
12-
"info.cluster.sync.no_missing_files": "没有缺失文件",
13-
"info.cluster.sync.no_files": "没有新文件",
1437
"info.download.configuration": "下载来源 [${source}] 并发 [${concurrency}]",
15-
"info.cluster.request_cert": "请求节点 [${id}] 证书",
1638
"info.web.access_log": "${host} - ${address} | ${total_time} | ${method} ${status} | ${path} - ${user_agent}",
17-
"info.cluster.disable": "节点 [${id}] 下线",
18-
"info.cluster.want_enable": "节点 [${id}] 上线",
19-
"info.cluster.enable": "节点 [${id}] 已上线",
20-
"info.cluster.message": "节点 [${id}] 消息 [${msg}]",
21-
"info.cluster.retry": "节点 [${id}] 将在 [${time}s] 后尝试重新上线",
2239
"info.web.byoc": "证书类型 [${type}]",
40+
"info.web.forward.pub_port": "公共端口 [${port}]",
2341
"success.cluster.keepalive": "节点 [${id}] 服务了 [${hits}] 个文件 总计 [${bytes}iB] 延迟 [${delay}ms]",
24-
"error.core.initialize.storages": "无法初始化存储",
25-
"error.core.initialize.missing": "当前加载节点数 [${clusters}] 存储数 [${storages}]",
26-
"error.web.forward.pub_port": "公共端口 [${port}] 错误",
27-
"error.cluster.refresh_token": "刷新节点 [${id}] Token 失败",
28-
"error.cluster.exception": "节点 [${id}] 异常:[${msg}]",
29-
"error.cluster.request_cert.error": "节点 [${id}] 申请证书失败",
30-
"error.cluster.enable": "节点 [${id}] 上线失败 [${err}]",
31-
"error.cluster.enable.timeout": "节点 [${id}] 注册超时",
32-
"error.web.certificates": "没有可用证书",
33-
"error.web.tls_listener": "TLS 监听器错误",
34-
"error.cluster.kicked": "节点 [${id}] 被主控踢出下线",
35-
"warning.cluster.warden": "节点 [${id}] 巡检:[${msg}]",
3642
"warning.cluster.keepalive": "节点 [${id}] 保活失败 (${failed}/3)",
37-
"debug.web.uvicorn.port": "Web 服务器监听端口 [${port}]",
38-
"debug.web.forward.tls_port": "TLS 端口在 [${port}] 上开启",
39-
"debug.cluster.refresh_token.schedule": "下一次节点 [${id}] Token 刷新将在 [${next}] 秒后进行",
40-
"debug.cluster.get_files": "获取节点 [${id}] 文件列表 大小 [${size}] 数量 [${count}] 最后修改日期 [${last_modified}]",
41-
"debug.cluster.connected": "节点 [${id}] 已连接至主控",
42-
"debug.cluster.disconnected": "节点 [${id}] 已断开连接"
43-
}
43+
"warning.cluster.warden": "节点 [${id}] 巡检:[${msg}]"
44+
}

0 commit comments

Comments
 (0)