()
| 1827 | } |
| 1828 | |
| 1829 | fn 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 | |
| 1861 | fn print_service_start_result(metadata: &ServiceMetadata, started: bool) -> anyhow::Result<()> { |
| 1862 | println_json(&serde_json::json!({ |
no test coverage detected