mirror of
https://github.com/getnora-io/nora.git
synced 2026-04-13 00:20:33 +00:00
fix(io): replace blocking I/O with async in hot paths
Three subsystems were using std::fs (blocking) inside async context, which stalls the tokio runtime thread during I/O: - DashboardMetrics::save(): now uses tokio::fs::write + rename - TokenStore::flush_last_used(): now uses tokio::fs for batch updates - AuditLog::log(): moved file write to spawn_blocking (fire-and-forget) The background task and shutdown handler now properly .await the async save/flush methods. AuditLog writer wrapped in Arc for cross-thread access from spawn_blocking.
This commit is contained in:
@@ -441,9 +441,9 @@ async fn run_server(config: Config, storage: Storage) {
|
||||
let mut interval = tokio::time::interval(std::time::Duration::from_secs(30));
|
||||
loop {
|
||||
interval.tick().await;
|
||||
metrics_state.metrics.save();
|
||||
metrics_state.metrics.save().await;
|
||||
if let Some(ref token_store) = metrics_state.tokens {
|
||||
token_store.flush_last_used();
|
||||
token_store.flush_last_used().await;
|
||||
}
|
||||
registry::docker::cleanup_expired_sessions(&metrics_state.upload_sessions);
|
||||
}
|
||||
@@ -459,7 +459,7 @@ async fn run_server(config: Config, storage: Storage) {
|
||||
.expect("Server error");
|
||||
|
||||
// Save metrics on shutdown
|
||||
state.metrics.save();
|
||||
state.metrics.save().await;
|
||||
|
||||
info!(
|
||||
uptime_seconds = state.start_time.elapsed().as_secs(),
|
||||
|
||||
Reference in New Issue
Block a user