Skip to content
Merged

2.2.0 #309

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
691 changes: 691 additions & 0 deletions backend/app/core/ap_scheduler.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion backend/app/core/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def get_dynamic_router() -> APIRouter:
if router_id not in seen_router_ids:
seen_router_ids.add(router_id)
container_router.include_router(attr_value)
log.debug(f"📌 注册路由 {attr_name} 到容器 {prefix}")

except Exception as e:
log.error(f"❌️ 处理模块 {module_path} 失败: {e!s}")
Expand Down
17 changes: 7 additions & 10 deletions backend/app/plugin/init_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[Any, Any]:
"""
from app.api.v1.module_system.dict.service import DictDataService
from app.api.v1.module_system.params.service import ParamsService
from app.plugin.module_task.job.tools.ap_scheduler import SchedulerUtil
from app.core.ap_scheduler import SchedulerUtil

try:
await InitializeData().init_db()
Expand All @@ -49,7 +49,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[Any, Any]:
log.info("✅ Redis系统配置初始化完成")
await DictDataService().init_dict_service(redis=app.state.redis)
log.info("✅ Redis数据字典初始化完成")
await SchedulerUtil.init_system_scheduler(redis=app.state.redis)
await SchedulerUtil.init_scheduler(redis=app.state.redis)
log.info("✅ 定时任务调度器初始化完成")
await FastAPILimiter.init(
redis=app.state.redis,
Expand All @@ -62,15 +62,14 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[Any, Any]:
# 导入并显示最终的启动信息面板
from app.common.enums import EnvironmentEnum

scheduler_jobs_count = len(SchedulerUtil.get_all_jobs())
scheduler_status = SchedulerUtil.get_job_status()
console_run(
host=settings.SERVER_HOST,
port=settings.SERVER_PORT,
reload=settings.ENVIRONMENT == EnvironmentEnum.DEV,
database_ready=True,
redis_ready=True,
scheduler_jobs=scheduler_jobs_count,
scheduler_status=scheduler_status,
scheduler_ready=SchedulerUtil.is_running(),
limiter_ready=True,
)

except Exception as e:
Expand All @@ -80,11 +79,9 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[Any, Any]:
yield

try:
await import_modules_async(
modules=settings.EVENT_LIST, desc="全局事件", app=app, status=False
)
await import_modules_async(modules=settings.EVENT_LIST, desc="全局事件", app=app, status=False)
log.info("✅ 全局事件模块卸载完成")
await SchedulerUtil.close_system_scheduler()
await SchedulerUtil.shutdown(wait=False)
log.info("✅ 定时任务调度器已关闭")
await FastAPILimiter.close()
log.info("✅ 请求限制器已关闭")
Expand Down
Loading