diff --git a/config/framework/base_config.yaml.example b/config/framework/base_config.yaml.example index fad04b6..b3d3dfa 100644 --- a/config/framework/base_config.yaml.example +++ b/config/framework/base_config.yaml.example @@ -11,7 +11,7 @@ plugins: auto_load: true hot_reload: true max_retry_count: 3 - isolation: true + isolation: false # 自动启动脚本 — 框架启动时后台拉起 auto_start_scripts: enabled: true diff --git a/docs/SenSu 插件开发详细指南.md b/docs/SenSu 插件开发详细指南.md index e275b29..10fc181 100644 --- a/docs/SenSu 插件开发详细指南.md +++ b/docs/SenSu 插件开发详细指南.md @@ -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 # 健康检查间隔(秒) diff --git a/plugins/example_plugin/config.yaml b/plugins/example_plugin/config.yaml index 3cd7d09..4c8c4b5 100644 --- a/plugins/example_plugin/config.yaml +++ b/plugins/example_plugin/config.yaml @@ -9,6 +9,7 @@ settings: enabled: true auto_start: true log_level: "INFO" + isolation: false # 示例功能配置 features: diff --git a/plugins/sentinel/__init__.py b/plugins/sentinel/__init__.py index 9f8a0c6..b4ed5bf 100644 --- a/plugins/sentinel/__init__.py +++ b/plugins/sentinel/__init__.py @@ -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) diff --git a/plugins/sentinel/config.yaml b/plugins/sentinel/config.yaml index 345f35b..d18c756 100644 --- a/plugins/sentinel/config.yaml +++ b/plugins/sentinel/config.yaml @@ -11,6 +11,6 @@ nodes: settings: auto_start: true isolation: false - poll_interval: 3 + poll_interval: 2 request_timeout: 5 version: 1.0.0 diff --git a/services/init_service.py b/services/init_service.py index c3bd043..57f3cd2 100644 --- a/services/init_service.py +++ b/services/init_service.py @@ -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,