tokio-cron-scheduler icon indicating copy to clipboard operation
tokio-cron-scheduler copied to clipboard

The features "signal" didn't work when combined with Axum

Open linyihai opened this issue 9 months ago • 3 comments

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.

linyihai avatar May 14 '24 09:05 linyihai