Checks if the specified proxy container is currently running.
(&self, container_name: &str)
| 373 | |
| 374 | /// Checks if the specified proxy container is currently running. |
| 375 | pub async fn is_proxy_running(&self, container_name: &str) -> Result<bool> { |
| 376 | match self.docker_client.inspect_container(container_name).await { |
| 377 | Ok(json_data) => { |
| 378 | let data: serde_json::Value = serde_json::from_str(&json_data) |
| 379 | .map_err(|e| anyhow::anyhow!("Failed to parse container info: {e}"))?; |
| 380 | Ok(data |
| 381 | .get("State") |
| 382 | .and_then(|s| s.get("Running")) |
| 383 | .and_then(|r| r.as_bool()) |
| 384 | .unwrap_or(false)) |
| 385 | } |
| 386 | Err(e) if e.to_lowercase().contains("no such container") => Ok(false), |
| 387 | Err(e) => Err(anyhow::anyhow!(e)), |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | /// Counts the number of agent networks the specified proxy is connected to. |
| 392 | /// |