Stops the proxy if no agents are connected, without acquiring the lock. This is safe to call during shutdown when all workers have been drained and no new tasks can start. Skipping the lock avoids potential deadlocks during the shutdown sequence.
(&self, proxy_config: &ResolvedProxyConfig)
| 501 | /// and no new tasks can start. Skipping the lock avoids potential deadlocks |
| 502 | /// during the shutdown sequence. |
| 503 | pub async fn force_stop_proxy(&self, proxy_config: &ResolvedProxyConfig) -> Result<bool> { |
| 504 | let container_name = proxy_config.proxy_container_name(); |
| 505 | |
| 506 | if !self.is_proxy_running(&container_name).await? { |
| 507 | return Ok(false); |
| 508 | } |
| 509 | |
| 510 | let agent_count = self.count_connected_agents(&container_name).await?; |
| 511 | |
| 512 | if agent_count == 0 { |
| 513 | self.stop_proxy(&container_name).await?; |
| 514 | Ok(true) |
| 515 | } else { |
| 516 | Ok(false) |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | /// Conditionally stops the proxy by container name if no agents are connected. |
| 521 | async fn maybe_stop_proxy_by_name(&self, container_name: &str) { |