feat(调度任务): 实现调度任务管理功能
新增调度任务模块,支持任务的增删改查、启停及手动执行 - 后端添加 schedule_job 模型、服务、路由及调度器工具类 - 前端新增调度任务管理页面 - 修改 flow 相关接口将 id 类型从 String 改为 i64 - 添加 tokio-cron-scheduler 依赖实现定时任务调度 - 初始化时加载已启用任务并注册到调度器
This commit is contained in:
@ -70,6 +70,14 @@ async fn main() -> anyhow::Result<()> {
|
||||
// run migrations
|
||||
migration::Migrator::up(&db, None).await.expect("migration up");
|
||||
|
||||
// 初始化并启动调度器(仅启动,不加载DB)
|
||||
if let Err(e) = crate::utils::init_scheduler().await { tracing::error!(target = "udmin", error = %e, "init scheduler failed"); }
|
||||
|
||||
// 由 service 层加载启用任务并注册到调度器
|
||||
if let Err(e) = services::schedule_job_service::init_load_enabled_and_register(&db).await {
|
||||
tracing::error!(target = "udmin", error = %e, "init schedule jobs failed");
|
||||
}
|
||||
|
||||
let allow_origins = std::env::var("CORS_ALLOW_ORIGINS").unwrap_or_else(|_| "http://localhost:5173".into());
|
||||
let origin_values: Vec<HeaderValue> = allow_origins
|
||||
.split(',')
|
||||
|
||||
Reference in New Issue
Block a user