Stops and removes the specified proxy container.
(&self, container_name: &str)
| 338 | |
| 339 | /// Stops and removes the specified proxy container. |
| 340 | pub async fn stop_proxy(&self, container_name: &str) -> Result<()> { |
| 341 | self.emit(ServerEvent::StatusMessage(format!( |
| 342 | "Stopping tsk proxy container {container_name}..." |
| 343 | ))); |
| 344 | |
| 345 | match self |
| 346 | .docker_client |
| 347 | .remove_container( |
| 348 | container_name, |
| 349 | Some(RemoveContainerOptions { |
| 350 | force: true, |
| 351 | ..Default::default() |
| 352 | }), |
| 353 | ) |
| 354 | .await |
| 355 | { |
| 356 | Ok(_) => { |
| 357 | self.emit(ServerEvent::StatusMessage(format!( |
| 358 | "Proxy container {container_name} stopped successfully" |
| 359 | ))); |
| 360 | Ok(()) |
| 361 | } |
| 362 | Err(e) if e.to_lowercase().contains("no such container") => { |
| 363 | self.emit(ServerEvent::StatusMessage(format!( |
| 364 | "Proxy container {container_name} was not running" |
| 365 | ))); |
| 366 | Ok(()) |
| 367 | } |
| 368 | Err(e) => Err(anyhow::anyhow!( |
| 369 | "Failed to stop proxy container {container_name}: {e}" |
| 370 | )), |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | /// Checks if the specified proxy container is currently running. |
| 375 | pub async fn is_proxy_running(&self, container_name: &str) -> Result<bool> { |