Skip to content

fix: handle SIGTERM #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

mxfactorial
Copy link

@github-actions github-actions bot added T-core Core library changes T-transport Transport layer changes labels Jun 19, 2025
@4t145
Copy link
Collaborator

4t145 commented Jun 19, 2025

We shouldn't handle specific signal here, we should wait for those signal outside and cancel the cancellation token.

@mxfactorial
Copy link
Author

here vs "outside" is another issue

this pr lets the process owner shut down their axum server

@4t145
Copy link
Collaborator

4t145 commented Jun 19, 2025

let me explain this, if you want to use graceful shutdown, you should await the shutdown signal and then trigger the cancellation token.

{
    let ct = CancellationToken::new();
    let config = new_config_with_ct(ct.clone());
    tokio::spawn(async move {
            graceful_shutdown().await;
            ct.cancel();
    });
    // create server
}

In your code, you firstly await cancellation token, and then waiting for shutdown signal, but ct has already been in responsibility of shutdown signal.

@mxfactorial
Copy link
Author

merge the code so process owners can shut down this axum server

"but they need to use CancellationToken"

no they don't

@4t145
Copy link
Collaborator

4t145 commented Jun 19, 2025

Can you provide some concrete example of why you need to put this code here, personally I don't see any necessity.

The disign here is user use cancellation token to shutdown the server. You cannot forcing people wait ctrl_c or SIGTERM, it is not always the case.

@mxfactorial
Copy link
Author

SIGTERM and cntrl c are concrete enough examples

and the code gives owners simple control over their processes

they dont need disign

thats your last response

@4t145
Copy link
Collaborator

4t145 commented Jun 20, 2025

Sorry maybe I'm not smart enough to understand you. Since you said that's your last response, I will close this pr.

@4t145 4t145 closed this Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-core Core library changes T-transport Transport layer changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tokio task not closed at shutdown
2 participants