MCPcopy Create free account
hub / github.com/Qovery/engine / run

Method run

app/src/deployment_manager/mod.rs:165–211  ·  view source on GitHub ↗
(mut self)

Source from the content-addressed store, hash-verified

163 }
164
165 pub async fn run(mut self) {
166 const SPAN_NAME: &str = "deploymnt_mngr";
167 let mut state = DeploymentManagerState::SeekingNewDeployment {};
168 let mut delay = None;
169 let mut span = span!(Level::INFO, SPAN_NAME, execution_id = field::Empty);
170 let mut run_once_started_deployment = false;
171
172 while state.does_execute_deployment() || !self.should_shutdown.load(Ordering::Relaxed) {
173 if let Some(delay) = delay {
174 tokio::time::sleep(delay).await;
175 }
176
177 let (new_state, new_delay, run_outcome) = self.run_exec_state(state).instrument(span.clone()).await;
178 let should_stop_run_once = self.run_mode == DeploymentManagerRunMode::RunOnce
179 && (run_outcome == DeploymentManagerRunOutcome::NoDeploymentAvailable
180 || (run_once_started_deployment
181 && matches!(new_state, DeploymentManagerState::SeekingNewDeployment {})));
182 run_once_started_deployment |= matches!(
183 new_state,
184 DeploymentManagerState::ExecutingDeployment { .. }
185 | DeploymentManagerState::ExecutingDeploymentTask { .. }
186 | DeploymentManagerState::ResumingDeploymentTask { .. }
187 );
188
189 state = new_state;
190 delay = new_delay;
191
192 // Add some Hook on transition change for metrics and tracing
193 match &state {
194 DeploymentManagerState::SeekingNewDeployment { .. } => {
195 METRICS_NB_RUNNING_TASKS.set(0);
196 span = span!(Level::INFO, SPAN_NAME, execution_id = field::Empty);
197 }
198 DeploymentManagerState::ExecutingDeployment { deployment, .. } => {
199 METRICS_NB_RUNNING_TASKS.set(1);
200 span = span!(Level::INFO, SPAN_NAME, execution_id = deployment.deployment_info.execution_id);
201 }
202 DeploymentManagerState::ExecutingDeploymentTask { .. } => {}
203 DeploymentManagerState::ResumingDeploymentTask { .. } => {}
204 }
205
206 if should_stop_run_once {
207 info!("RUN_ONCE mode completed, stopping deployment manager");
208 break;
209 }
210 }
211 }
212
213 async fn run_exec_state(
214 &mut self,

Calls 6

run_exec_stateMethod · 0.80
writeMethod · 0.80
sendMethod · 0.80
should_cancelMethod · 0.80
cloneMethod · 0.45