feat: implement full-stack TaskPilot scheduler

This commit is contained in:
2026-10-18 22:05:45 +08:00
parent d88c21753d
commit 8ce02af13a
72 changed files with 17812 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
pub mod api;
pub mod cron;
pub mod database;
pub mod error;
pub mod process_job;
pub mod runs;
pub mod scheduler;
pub mod security;
pub mod state;
pub mod tasks;
use axum::Router;
use sqlx::SqlitePool;
use tower_http::{
services::{ServeDir, ServeFile},
trace::TraceLayer,
};
pub async fn app(
pool: SqlitePool,
logs_dir: std::path::PathBuf,
) -> crate::error::ApiResult<Router> {
let state = state::AppState::start(pool, logs_dir).await?;
Ok(router(state))
}
pub fn router(state: state::AppState) -> Router {
api::router(state).layer(TraceLayer::new_for_http())
}
pub fn router_with_static(state: state::AppState, static_dir: std::path::PathBuf) -> Router {
let index = static_dir.join("index.html");
let router = if index.is_file() {
api::router(state)
.fallback_service(ServeDir::new(&static_dir).fallback(ServeFile::new(index)))
} else {
api::router(state)
};
router.layer(TraceLayer::new_for_http())
}