feat: report daemon uptime in status

This commit is contained in:
Eric Wendland 2026-07-05 18:14:52 +02:00
commit 2d314e85bf
7 changed files with 50 additions and 8 deletions

View file

@ -68,7 +68,7 @@ use runtime::{
use std::collections::{BTreeMap, BTreeSet};
use std::path::{Component, Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::time::Duration;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use sync::{
KvDocsState, load_live_sync_cursor, store_live_sync_cursor, sync_now, sync_status_local,
};
@ -185,6 +185,7 @@ pub struct LocalNode {
pub paths: GethPaths,
pub agent_id: String,
pub node_id: String,
pub daemon_started_at_ms: i64,
pub iroh_status: EndpointStatus,
iroh_endpoint: Arc<Mutex<Option<GethIrohEndpoint>>>,
iroh_blob_store: Arc<Mutex<Option<iroh_blobs::store::fs::FsStore>>>,
@ -262,6 +263,7 @@ pub fn init_node(paths: &GethPaths) -> Result<LocalNode, NodeError> {
paths: paths.clone(),
agent_id,
node_id,
daemon_started_at_ms: current_unix_ms(),
iroh_status: EndpointStatus::scaffolded(),
iroh_endpoint: Arc::new(Mutex::new(None)),
iroh_blob_store: Arc::new(Mutex::new(None)),
@ -275,6 +277,14 @@ pub fn init_node(paths: &GethPaths) -> Result<LocalNode, NodeError> {
})
}
fn current_unix_ms() -> i64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.as_millis()
.min(i64::MAX as u128) as i64
}
pub fn init_owned_node(
paths: &GethPaths,
options: InitOwnerOptions,
@ -5880,6 +5890,11 @@ pub fn handle_request(
socket: node.paths.socket_path(),
agent_id: node.agent_id.clone(),
node_id: node.node_id.clone(),
daemon_started_at_ms: node.daemon_started_at_ms,
daemon_uptime_seconds: current_unix_ms()
.saturating_sub(node.daemon_started_at_ms)
.max(0) as u64
/ 1000,
store_schema_version,
store_current_schema_version: geth_store::CURRENT_SCHEMA_VERSION,
store_journal_mode,