MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / wait_for_healthy

Function wait_for_healthy

e2e/rust/src/harness/cli.rs:27–52  ·  view source on GitHub ↗
(timeout: Duration)

Source from the content-addressed store, hash-verified

25}
26
27pub async fn wait_for_healthy(timeout: Duration) -> Result<(), String> {
28 let start = Instant::now();
29 let mut last_output: String;
30
31 loop {
32 let (output, code) = run_cli(&["status"]).await;
33 let clean = strip_ansi(&output);
34 let lower = clean.to_lowercase();
35 if code == 0
36 && (lower.contains("healthy")
37 || lower.contains("running")
38 || lower.contains("connected"))
39 {
40 return Ok(());
41 }
42 last_output = clean;
43
44 if start.elapsed() > timeout {
45 return Err(format!(
46 "gateway did not become healthy within {}s. Last output:\n{last_output}",
47 timeout.as_secs()
48 ));
49 }
50 sleep(Duration::from_secs(2)).await;
51 }
52}
53
54pub async fn sandbox_names() -> Result<Vec<String>, String> {
55 let (output, code) = run_cli(&["sandbox", "list", "--names"]).await;

Calls 2

strip_ansiFunction · 0.85
run_cliFunction · 0.70