diff --git a/Cargo.lock b/Cargo.lock index 16c59f8df..d66202320 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2686,6 +2686,7 @@ dependencies = [ "fuel-tx 0.35.3", "fuels", "hex", + "humantime", "hyper-rustls 0.23.2", "indicatif", "owo-colors", @@ -4378,6 +4379,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "0.14.27" diff --git a/plugins/forc-index/Cargo.toml b/plugins/forc-index/Cargo.toml index c3fc73661..767516404 100644 --- a/plugins/forc-index/Cargo.toml +++ b/plugins/forc-index/Cargo.toml @@ -23,6 +23,7 @@ fuel-indexer-lib = { workspace = true } fuel-tx = { features = ["builder"], workspace = true } fuels = { default-features = false, workspace = true } hex = "0.4.3" +humantime = "2.1.0" hyper-rustls = { version = "0.23", features = ["http2"] } indicatif = "0.17" owo-colors = "1.3.0" diff --git a/plugins/forc-index/src/ops/forc_index_status.rs b/plugins/forc-index/src/ops/forc_index_status.rs index 5fd4fd8e3..41046e1ea 100644 --- a/plugins/forc-index/src/ops/forc_index_status.rs +++ b/plugins/forc-index/src/ops/forc_index_status.rs @@ -29,15 +29,34 @@ pub async fn status( return Ok(()); } - let res_json = res + let result = res .json::>() .await .expect("Failed to read JSON response."); - info!( - "\n✅ Sucessfully fetched service health:\n\n{}", - to_string_pretty(&res_json).unwrap() - ); + info!("\n✅ Successfully fetched service health:\n"); + + let client_status = result + .get("client_status") + .and_then(|x| x.as_str()) + .unwrap_or("missing"); + let database_status = result + .get("database_status") + .and_then(|x| x.as_str()) + .unwrap_or("missing"); + let uptime = result + .get("uptime") + .and_then(|x| x.as_str()) + .and_then(|x| x.to_string().parse::().ok()) + .map(|x| { + humantime::format_duration(std::time::Duration::from_secs(x)) + .to_string() + }) + .unwrap_or("missing".to_string()); + + info!("client status: {client_status}"); + info!("database status: {database_status}"); + info!("uptime: {uptime}\n"); } Err(e) => { error!("\n❌ Could not connect to indexer service:\n'{e}'"); @@ -70,6 +89,7 @@ pub async fn status( .await .expect("Failed to read JSON response."); + info!("indexers:"); print_indexers(result); } Err(e) => { @@ -121,7 +141,7 @@ fn print_indexers(indexers: Vec) { }; println!("{} {} {}", ng2, ig1, indexer.identifier); println!("{} {} • id: {}", ng2, ig2, indexer.id); - println!("{} {} • created_at: {}", ng2, ig2, indexer.created_at); + println!("{} {} • created at: {}", ng2, ig2, indexer.created_at); println!("{} {} • pubkey: {:?}", ng2, ig2, indexer.pubkey); } if !is_last_namespace {