-
Notifications
You must be signed in to change notification settings - Fork 358
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
I use SystemRunner::block_on() in my main function to run my http server. It is ergonomic since it passes through my std::process::ExitCode return value from my future. Now I would like to use System::current().stop() to shutdown my server. Unfortunately, I don't see a way to await the stop event within my block_on future.
One possible design:
fn main() -> ExitCode {
let (runtime, stop) = System::new().into_parts(); // or `into_runtime_and_stop()`
runtime.block_on(async move {
let http_server = axum::serve(...System::current().stop()...);
tokio::select {
_ = stop => {
return ExitCode::SUCCESS;
}
_ = http_server => {
return ExitCode::FAILURE;
}
}
})
}I considered multiple workarounds, and am currently constructing an extra Oneshot channel and passing it around my application (losing the benefit of System::current().stop() working anywhere).
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed