diff --git a/crates/event-notifier/src/config.rs b/crates/event-notifier/src/config.rs index ae718abc..ab46d8e8 100644 --- a/crates/event-notifier/src/config.rs +++ b/crates/event-notifier/src/config.rs @@ -149,7 +149,6 @@ impl NotifierConfig { ) .build() .unwrap_or_default(); - println!("Loaded config: {:?}", app_config); match app_config.try_deserialize::() { Ok(app_config) => { println!("Parsed AppConfig: {:?} \n", app_config); diff --git a/crates/obs/src/config.rs b/crates/obs/src/config.rs index a9e62016..33f974f9 100644 --- a/crates/obs/src/config.rs +++ b/crates/obs/src/config.rs @@ -178,7 +178,6 @@ pub struct AppConfig { pub logger: Option, } -// 为 AppConfig 实现 Default impl AppConfig { pub fn new() -> Self { Self { @@ -189,6 +188,7 @@ impl AppConfig { } } +// implement default for AppConfig impl Default for AppConfig { fn default() -> Self { Self::new() diff --git a/crates/obs/src/system/collector.rs b/crates/obs/src/system/collector.rs index 335c581e..c4184051 100644 --- a/crates/obs/src/system/collector.rs +++ b/crates/obs/src/system/collector.rs @@ -54,22 +54,22 @@ impl Collector { self.system .refresh_processes(sysinfo::ProcessesToUpdate::Some(&[self.pid]), true); - // 刷新网络接口列表和统计数据 - self.networks.refresh(false); // 刷新网络统计数据 + // refresh the network interface list and statistics + self.networks.refresh(false); let process = self .system .process(self.pid) .ok_or_else(|| GlobalError::ProcessNotFound(self.pid.as_u32()))?; - // CPU 指标 + // CPU metrics let cpu_usage = process.cpu_usage(); self.metrics.cpu_usage.record(cpu_usage as f64, &[]); self.metrics .cpu_utilization .record((cpu_usage / self.core_count as f32) as f64, &self.attributes.attributes); - // 内存指标 + // Memory metrics self.metrics .memory_usage .record(process.memory() as i64, &self.attributes.attributes); @@ -77,7 +77,7 @@ impl Collector { .memory_virtual .record(process.virtual_memory() as i64, &self.attributes.attributes); - // 磁盘I/O指标 + // Disk I/O metrics let disk_io = process.disk_usage(); self.metrics.disk_io.record( disk_io.read_bytes as i64, @@ -88,11 +88,11 @@ impl Collector { &[&self.attributes.attributes[..], &[KeyValue::new(DIRECTION, "write")]].concat(), ); - // 网络I/O指标(对应 /system/network/internode) + // Network I/O indicators (corresponding to /system/network/internode) let mut total_received: i64 = 0; let mut total_transmitted: i64 = 0; - // 按接口统计 + // statistics by interface for (interface_name, data) in self.networks.iter() { total_received += data.total_received() as i64; total_transmitted += data.total_transmitted() as i64; @@ -122,7 +122,7 @@ impl Collector { .concat(), ); } - // 全局统计 + // global statistics self.metrics.network_io.record( total_received, &[&self.attributes.attributes[..], &[KeyValue::new(DIRECTION, "received")]].concat(), @@ -132,12 +132,12 @@ impl Collector { &[&self.attributes.attributes[..], &[KeyValue::new(DIRECTION, "transmitted")]].concat(), ); - // 进程状态指标(对应 /system/process) + // Process status indicator (corresponding to /system/process) let status_value = match process.status() { ProcessStatus::Run => 0, ProcessStatus::Sleep => 1, ProcessStatus::Zombie => 2, - _ => 3, // 其他状态 + _ => 3, // other status }; self.metrics.process_status.record( status_value, @@ -148,7 +148,7 @@ impl Collector { .concat(), ); - // GPU 指标(可选) + // GPU Metrics (Optional) Non-MacOS self.gpu_collector.collect(&self.metrics, &self.attributes)?; Ok(()) diff --git a/rustfs/src/main.rs b/rustfs/src/main.rs index ba24558e..ba1579ab 100644 --- a/rustfs/src/main.rs +++ b/rustfs/src/main.rs @@ -451,17 +451,9 @@ async fn run(opt: config::Opt) -> Result<()> { } } worker_state_manager.update(ServiceState::Stopping); - // tokio::select! { - // () = graceful.shutdown() => { - // debug!("Gracefully shutdown!"); - // }, - // () = tokio::time::sleep(std::time::Duration::from_secs(10)) => { - // debug!("Waited 10 seconds for graceful shutdown, aborting..."); - // } - // } match Arc::try_unwrap(graceful) { Ok(g) => { - // 成功获取唯一所有权,可以调用 shutdown + // Successfully obtaining unique ownership, you can call shutdown tokio::select! { () = g.shutdown() => { debug!("Gracefully shutdown!"); @@ -472,10 +464,9 @@ async fn run(opt: config::Opt) -> Result<()> { } } Err(arc_graceful) => { - // 还有其他引用存在,无法获取唯一所有权 - debug!("Cannot perform graceful shutdown, other references exist"); + // There are other references that cannot be obtained for unique ownership error!("Cannot perform graceful shutdown, other references exist err: {:?}", arc_graceful); - // 在这种情况下,我们只能等待超时 + // In this case, we can only wait for the timeout tokio::time::sleep(Duration::from_secs(10)).await; debug!("Timeout reached, forcing shutdown"); }