默认关闭插件热加载扫盘监听

This commit is contained in:
liuwei
2026-05-06 11:07:47 +08:00
parent 831a61e7ea
commit b4c046a594
4 changed files with 51 additions and 2 deletions

View File

@@ -115,8 +115,17 @@ class Robot:
self.plugin_manager = PluginManager(plugin_dir=getattr(self.config, "plugin_dir", "plugins"))
self.plugin_manager.set_system_context(self.system_context)
self.plugins = self.plugin_manager.load_all_plugins()
# 热加载改为低频扫描:每 60 秒检查一次插件文件变动
self.plugin_manager.start_hot_reload_watcher(interval_seconds=60.0)
# 插件热加载默认关闭:
# 1. 它会持续轮询插件目录并调用 discover_plugins线上运行会产生额外扫盘开销
# 2. 对当前以“稳定运行”为主的场景,这类自动热更新收益远低于成本;
# 3. 若后续确实需要在线调试插件,可通过配置重新打开,并把轮询间隔调大。
hot_reload_cfg = dict(getattr(self.config, "plugin_hot_reload", {}) or {})
if bool(hot_reload_cfg.get("enabled")):
interval_seconds = max(float(hot_reload_cfg.get("interval_seconds", 600) or 600), 60.0)
self.plugin_manager.start_hot_reload_watcher(interval_seconds=interval_seconds)
self.LOG.info(f"插件热加载监听已启用,轮询间隔 {interval_seconds}s")
else:
self.LOG.info("插件热加载监听已禁用,启动阶段不再自动扫盘检查插件变更")
self.system_job_loader = SystemJobLoader(self, self.system_job_db)
self.system_job_loader.init_and_load()
self.plugin_schedule_manager = PluginScheduleManager(self.plugin_manager, self.plugin_schedule_db)