MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / service_status

Function service_status

packages/server/src/main.rs:1829–1859  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1827}
1828
1829fn service_status() -> anyhow::Result<()> {
1830 if let Some(result) = service::active()? {
1831 let metadata = metadata_from_launch_agent(result)?;
1832 let healthy = service_is_healthy(&metadata);
1833 println_json(&serde_json::json!({
1834 "running": healthy,
1835 "healthy": healthy,
1836 "processRunning": true,
1837 "stale": false,
1838 "service": metadata,
1839 }))?;
1840 return Ok(());
1841 }
1842 let metadata = read_service_metadata()?;
1843 let process_running = metadata
1844 .as_ref()
1845 .is_some_and(|metadata| process_exists(metadata.pid));
1846 let healthy = metadata.as_ref().is_some_and(service_is_healthy);
1847 let stale = metadata.is_some() && !process_running && !healthy;
1848 if stale {
1849 let _ = fs::remove_file(service_metadata_path()?);
1850 }
1851 println_json(&serde_json::json!({
1852 "running": healthy,
1853 "healthy": healthy,
1854 "processRunning": process_running,
1855 "stale": stale,
1856 "service": if stale { None } else { metadata.clone() },
1857 "staleService": if stale { metadata } else { None },
1858 }))
1859}
1860
1861fn print_service_start_result(metadata: &ServiceMetadata, started: bool) -> anyhow::Result<()> {
1862 println_json(&serde_json::json!({

Callers 1

mainFunction · 0.85

Calls 7

activeFunction · 0.85
service_is_healthyFunction · 0.85
println_jsonFunction · 0.85
read_service_metadataFunction · 0.85
service_metadata_pathFunction · 0.85
process_existsFunction · 0.70

Tested by

no test coverage detected