add full gc scheduler

This commit is contained in:
jxxghp
2025-09-08 10:49:09 +08:00
parent 704364061c
commit 481f1f9d30
3 changed files with 153 additions and 0 deletions
+26
View File
@@ -30,6 +30,7 @@ from app.helper.wallpaper import WallpaperHelper
from app.log import logger
from app.schemas import Notification, NotificationType, Workflow, ConfigChangeEventData
from app.schemas.types import EventType, SystemConfigKey
from app.utils.gc import auto_gc
from app.utils.singleton import SingletonClass
from app.utils.timer import TimerUtils
@@ -181,6 +182,11 @@ class Scheduler(metaclass=SingletonClass):
"name": "订阅日历缓存",
"func": SubscribeChain().cache_calendar,
"running": False
},
"full_gc": {
"name": "主动内存回收",
"func": self.full_gc,
"running": False
}
}
@@ -413,6 +419,19 @@ class Scheduler(metaclass=SingletonClass):
}
)
# 主动内存回收
if settings.MEMORY_GC_INTERVAL:
self._scheduler.add_job(
self.start,
"interval",
id="full_gc",
name="主动内存回收",
hours=settings.MEMORY_GC_INTERVAL,
kwargs={
'job_id': 'full_gc'
}
)
# 初始化工作流服务
self.init_workflow_jobs()
@@ -747,6 +766,13 @@ class Scheduler(metaclass=SingletonClass):
"""
SchedulerChain().clear_cache()
@auto_gc
def full_gc(self):
"""
主动内存回收
"""
pass
def user_auth(self):
"""
用户认证检查