From dc61d0720689c3cd57697e886cb0fe539e248674 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 9 Apr 2025 23:45:53 +0800 Subject: [PATCH] improve code --- rustfs/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index 2e6760ed4..9d211859c 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -62,7 +62,7 @@ fn notify_systemd(state: &str) { _ => { warn!("Unsupported state passed to notify_systemd: {}", state); return; - }, + } }; if let Err(e) = notify(false, &[notify_state]) { @@ -70,11 +70,12 @@ fn notify_systemd(state: &str) { } else { debug!("Successfully notified systemd: {}", state); } + info!("Systemd notifications are enabled on linux (state: {})", state); } #[cfg(not(target_os = "linux"))] fn notify_systemd(state: &str) { - debug!("Systemd notifications are not available on this platform (state: {})", state); + info!("Systemd notifications are not available on this platform not linux (state: {})", state); } #[allow(dead_code)] @@ -284,7 +285,7 @@ async fn run(opt: config::Opt) -> Result<()> { None }; - // Create a oneshot channel to wait for the service to start + // Create an oneshot channel to wait for the service to start let (tx, rx) = tokio::sync::oneshot::channel(); tokio::spawn(async move { @@ -420,9 +421,13 @@ async fn run(opt: config::Opt) -> Result<()> { }); } + // 执行休眠 1 秒钟 + tokio::time::sleep(std::time::Duration::from_secs(1)).await; // Wait for the HTTP service to finish starting if rx.await.is_ok() { notify_systemd("ready"); + } else { + info!("Failed to start the server"); } tokio::select! {