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:
@@ -11,7 +11,7 @@ plugins:
|
||||
auto_load: true
|
||||
hot_reload: true
|
||||
max_retry_count: 3
|
||||
isolation: true
|
||||
isolation: false
|
||||
# 自动启动脚本 — 框架启动时后台拉起
|
||||
auto_start_scripts:
|
||||
enabled: true
|
||||
|
||||
@@ -156,6 +156,7 @@ license: "MIT" # 开源许可证
|
||||
settings:
|
||||
enabled: true # 是否启用
|
||||
auto_start: true # 是否自动启动
|
||||
isolation: false # 进程隔离: true=独立子进程(无WebUI), false=框架内运行(支持WebUI/网络路由)
|
||||
log_level: "INFO" # 日志级别:DEBUG, INFO, WARNING, ERROR
|
||||
max_retry_count: 3 # 失败重试次数
|
||||
health_check_interval: 60 # 健康检查间隔(秒)
|
||||
|
||||
@@ -9,6 +9,7 @@ settings:
|
||||
enabled: true
|
||||
auto_start: true
|
||||
log_level: "INFO"
|
||||
isolation: false
|
||||
|
||||
# 示例功能配置
|
||||
features:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ nodes:
|
||||
settings:
|
||||
auto_start: true
|
||||
isolation: false
|
||||
poll_interval: 3
|
||||
poll_interval: 2
|
||||
request_timeout: 5
|
||||
version: 1.0.0
|
||||
|
||||
@@ -228,7 +228,7 @@ class InitService:
|
||||
'auto_load': True,
|
||||
'hot_reload': True,
|
||||
'max_retry_count': 3,
|
||||
'isolation': True, # 生产默认进程隔离,插件崩溃不影响框架
|
||||
'isolation': False, # 默认不隔离 (需要 Web 页面的插件必须非隔离)
|
||||
},
|
||||
'auto_start_scripts': {
|
||||
'enabled': True,
|
||||
|
||||
Reference in New Issue
Block a user