tokio-cron-scheduler
tokio-cron-scheduler copied to clipboard
The features "signal" didn't work when combined with Axum
I use tokio-cron-scheduler
to run schedule job, and run together with Axum
#[tokio::main]
async fn main() {
// Build our application with a single route.
let ctx = Context::new();
let app = axum::Router::new()
.route("/", axum::routing::get(|| async move { "Hello, World!" }))
.route("/metrics", axum::routing::get(metrics::test_metrics))
.layer(ServiceBuilder::new().layer(Extension(ctx.test_metrics())));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3030").await.unwrap();
scheduler::schedule(&ctx).await.unwrap();
axum::serve(listener, app).await.unwrap();
}
I can't use ctrl + c
to stop the running process.