MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / shutdown

Method shutdown

supervisor/src/supervisor.rs:116–137  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

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}

Callers 1

perform_shutdownFunction · 0.45

Calls 4

set_freezedMethod · 0.80
is_runningMethod · 0.80
lockMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected