Don't run server in tokio::spawn
This commit is contained in:
parent
2e05bd5fff
commit
d1c5d5203b
|
@ -371,21 +371,6 @@ async fn main_cli() -> Result<()> {
|
|||
|
||||
tracing::info!("Listening on {}", args.listen);
|
||||
|
||||
let server = axum::Server::bind(&args.listen)
|
||||
.serve(app.into_make_service())
|
||||
.with_graceful_shutdown(async move {
|
||||
shutdown_receiver.await.ok();
|
||||
tracing::info!("Shutting down");
|
||||
});
|
||||
|
||||
// Spawn here so that post-startup tasks can proceed
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = server.await {
|
||||
tracing::error!("failed to start up daemon: {e}");
|
||||
exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
// Notify of startup via HTTP
|
||||
if let Some(startup_notification_url) = args.startup_notification_url {
|
||||
tracing::debug!("Startup notification via HTTP POST to {startup_notification_url}");
|
||||
|
@ -427,11 +412,20 @@ async fn main_cli() -> Result<()> {
|
|||
tracing::debug!("Created startup notification file at {startup_notification_file_path:?}");
|
||||
}
|
||||
|
||||
let ret = axum::Server::bind(&args.listen)
|
||||
.serve(app.into_make_service())
|
||||
.with_graceful_shutdown(async move {
|
||||
shutdown_receiver.await.ok();
|
||||
tracing::info!("Shutting down");
|
||||
})?;
|
||||
|
||||
// Notify diagnostics endpoint
|
||||
if let Some(diagnostic_endpoint) = diagnostic_endpoint {
|
||||
state.metrics.send(diagnostic_endpoint).await;
|
||||
}
|
||||
|
||||
ret?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue