fix: Sentinel SSE 每次轮询都推送 (实时性) + isolation 默认 false + 文档

Sentinel:
- poll_interval 3s→2s, 每次轮询都推 SSE (不再等状态变化)
- 解决稳定状态下数据更新不实时问题

插件系统:
- 默认 isolation: false (避免插件 WebUI 不显示)
- example_plugin 显式设置 isolation: false
- 插件开发指南: settings 示例增加 isolation 说明

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
qinglong
2026-06-13 17:54:39 +08:00
parent af16549524
commit b53410bc77
6 changed files with 8 additions and 11 deletions
+1
View File
@@ -9,6 +9,7 @@ settings:
enabled: true
auto_start: true
log_level: "INFO"
isolation: false
# 示例功能配置
features:
+3 -8
View File
@@ -175,23 +175,18 @@ class Plugin(PluginWebMixin):
async def _poll_loop(self, interval: int):
while self._running:
nodes = self._get_nodes()
changed = False
for node in nodes:
if not node.get("enabled", True):
continue
prev = _NODE_CACHE.get(node.get("id", ""), {})
online, sys_info, err = await self._fetch_system(node)
new_status = {
_NODE_CACHE[node.get("id", "")] = {
"online": online,
"system": sys_info or {},
"last_seen": time.time(),
"error": err if not online else "",
}
if (prev.get("online") != online
or abs(prev.get("last_seen", 0) - new_status["last_seen"]) > 5):
changed = True
_NODE_CACHE[node.get("id", "")] = new_status
if changed:
# 每次轮询都推送 SSE (确保实时性)
if nodes:
await self.push_sse_event("nodes_update", {"nodes": self._build_cache_list()})
await asyncio.sleep(interval)
+1 -1
View File
@@ -11,6 +11,6 @@ nodes:
settings:
auto_start: true
isolation: false
poll_interval: 3
poll_interval: 2
request_timeout: 5
version: 1.0.0