(&self)
| 114 | } |
| 115 | |
| 116 | pub async fn shutdown(&self) -> Result<()> { |
| 117 | self.set_freezed(true); |
| 118 | // Fixme: race condition here, there might be on going deployments |
| 119 | let mut n_running = 0; |
| 120 | for i in 0..10 { |
| 121 | n_running = 0; |
| 122 | for pair in self.processes.iter() { |
| 123 | let process = pair.value(); |
| 124 | let is_running = process.lock().is_running(); |
| 125 | if is_running { |
| 126 | process.stop().ok(); |
| 127 | n_running += 1; |
| 128 | } |
| 129 | } |
| 130 | if n_running == 0 { |
| 131 | return Ok(()); |
| 132 | } |
| 133 | info!("Waiting {n_running} processes to stop"); |
| 134 | tokio::time::sleep(Duration::from_millis(50 + 200 * i)).await; |
| 135 | } |
| 136 | bail!("Failed to stop {n_running} processes"); |
| 137 | } |
| 138 | } |
no test coverage detected