优化启动阶段插件与调度初始化耗时
This commit is contained in:
@@ -21,9 +21,9 @@ class PluginScheduleManager:
|
||||
self._schedule_job_map: Dict[int, str] = {}
|
||||
self._compensation_tolerance_seconds = 120
|
||||
|
||||
def init_and_load(self):
|
||||
def init_and_load(self, *, run_startup_compensation: bool = False):
|
||||
self.db.init_tables()
|
||||
self.reload_from_db()
|
||||
self.reload_from_db(run_startup_compensation=run_startup_compensation)
|
||||
|
||||
def migrate_from_system_jobs(self, system_job_db) -> Dict[str, int]:
|
||||
"""把历史系统任务配置迁移到插件任务表(幂等)。"""
|
||||
@@ -252,7 +252,7 @@ class PluginScheduleManager:
|
||||
self.db.create_log(schedule_id, status, summary, detail)
|
||||
return {"success": status == "success", "summary": summary, "detail": detail}
|
||||
|
||||
def reload_from_db(self):
|
||||
def reload_from_db(self, *, run_startup_compensation: bool = True):
|
||||
self.sync_defaults()
|
||||
|
||||
# 清理旧注册,避免重复
|
||||
@@ -281,7 +281,7 @@ class PluginScheduleManager:
|
||||
try:
|
||||
trigger_type = row.get("trigger_type", "at_times")
|
||||
trigger_config = row.get("trigger_config", {"time_list": ["09:00"]})
|
||||
if self._should_compensate_once(schedule_id, trigger_type, trigger_config):
|
||||
if run_startup_compensation and self._should_compensate_once(schedule_id, trigger_type, trigger_config):
|
||||
logger.warning(
|
||||
f"插件调度触发漏执行补偿: schedule_id={schedule_id}, "
|
||||
f"plugin={row.get('plugin_name')}, action={row.get('action_key')}"
|
||||
|
||||
Reference in New Issue
Block a user