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

Function doctor_check

crates/openshell-cli/src/run.rs:1561–1597  ·  view source on GitHub ↗

Validate system prerequisites for running a gateway. Checks Docker connectivity and reports the result. Returns exit code 0 if all checks pass, 1 otherwise.

()

Source from the content-addressed store, hash-verified

1559/// Checks Docker connectivity and reports the result. Returns exit code 0
1560/// if all checks pass, 1 otherwise.
1561pub fn doctor_check() -> Result<()> {
1562 use std::io::Write;
1563 let mut stdout = std::io::stdout().lock();
1564
1565 writeln!(stdout, "Checking system prerequisites...\n").into_diagnostic()?;
1566
1567 // --- Docker connectivity ---
1568 write!(stdout, " Docker ............. ").into_diagnostic()?;
1569 stdout.flush().into_diagnostic()?;
1570
1571 let output = Command::new("docker")
1572 .args(["info", "--format", "{{.ServerVersion}}"])
1573 .output()
1574 .into_diagnostic()
1575 .wrap_err("failed to execute docker info")?;
1576
1577 if output.status.success() {
1578 let version = String::from_utf8_lossy(&output.stdout);
1579 let version_str = version.trim();
1580 writeln!(stdout, "ok (version {version_str})").into_diagnostic()?;
1581
1582 // --- DOCKER_HOST ---
1583 write!(stdout, " DOCKER_HOST ........ ").into_diagnostic()?;
1584 match std::env::var("DOCKER_HOST") {
1585 Ok(val) => writeln!(stdout, "{val}").into_diagnostic()?,
1586 Err(_) => writeln!(stdout, "(not set, using default socket)").into_diagnostic()?,
1587 }
1588
1589 writeln!(stdout, "\nAll checks passed.").into_diagnostic()?;
1590 return Ok(());
1591 }
1592
1593 writeln!(stdout, "FAILED").into_diagnostic()?;
1594 writeln!(stdout).into_diagnostic()?;
1595 let stderr = String::from_utf8_lossy(&output.stderr);
1596 Err(miette::miette!("docker info failed: {}", stderr.trim()))
1597}
1598
1599fn sandbox_should_persist(keep: bool, forward: Option<&ForwardSpec>) -> bool {
1600 keep || forward.is_some()

Callers 1

mainFunction · 0.85

Calls 2

flushMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected