feat(#2289): push-based server-warning registry with RAII guard
This commit is contained in:
parent
d01d6d91e2
commit
9f98925c14
5 changed files with 361 additions and 34 deletions
|
|
@ -13,8 +13,8 @@ use hive_sh4re::{HostRequest, HostResponse};
|
|||
use hive_c0re::coordinator::{Coordinator, HiveEnv, ServeConfig};
|
||||
use hive_c0re::{
|
||||
agent_sockets, auto_update, broker, client, crash_watch, dashboard, dashboard_events, forge,
|
||||
job_queue, knowledge, matrix, mcp_sockets, migrate, reminder_scheduler,
|
||||
scheduled_prompts_worker, server, socket_server,
|
||||
host_stats, job_queue, knowledge, matrix, mcp_sockets, migrate, reminder_scheduler,
|
||||
scheduled_prompts_worker, server, socket_server, warnings,
|
||||
};
|
||||
|
||||
#[derive(Parser)]
|
||||
|
|
@ -340,6 +340,27 @@ async fn cmd_serve(
|
|||
}
|
||||
}
|
||||
});
|
||||
// Disk-pressure watch: raise a `disk_pressure` banner warning while the
|
||||
// host nix store is over threshold and clear it when back under, via the
|
||||
// push-based warnings registry. Replaces the old per-`/api/state`
|
||||
// `statvfs`. ~60s cadence; first tick fires immediately. The held guard
|
||||
// lives for the task's lifetime — dropping it (on shutdown) clears the
|
||||
// banner.
|
||||
let mut disk_shutdown = coord.shutdown_rx();
|
||||
tokio::spawn(async move {
|
||||
let mut disk_guard: Option<warnings::WarningGuard> = None;
|
||||
let interval = std::time::Duration::from_mins(1);
|
||||
loop {
|
||||
host_stats::refresh_disk_warning(&mut disk_guard);
|
||||
tokio::select! {
|
||||
() = tokio::time::sleep(interval) => {}
|
||||
_ = disk_shutdown.changed() => {
|
||||
tracing::info!("disk-pressure watch: shutdown signal received");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// Matrix user sweep: same shape — ensure every container has
|
||||
// an account on the local matrix-tuwunel homeserver with an
|
||||
// access_token persisted to `<state>/matrix-token`. No-op when
|
||||
|
|
|
|||
Loading…
Reference in a new issue