Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Commit

Permalink
fix: preemptively fix short lived workloads having no output
Browse files Browse the repository at this point in the history
This can be useful if a user hasn't had time to view the output yet.
The output will always be buffered for a few minutes before it is completely removed with the workload.

Signed-off-by: Nicholas Farshidmehr <[email protected]>
  • Loading branch information
definitelynobody authored and npmccallum committed Jul 24, 2022
1 parent a07331b commit 9cea32c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,14 @@ async fn root_post(
tokio::spawn(async move {
// Convert from minutes to seconds.
sleep(Duration::from_secs(ctx.timeout * 60)).await;

// Stop running the workload
if let Some(state) = OUT.write().await.get(&uuid) {
let _ = state.lock().await.exec.kill().await;
}

// Remove the workload state completely if it still exists
sleep(Duration::from_secs(5 * 60)).await;
OUT.write().await.remove(&uuid);
});

Expand Down

0 comments on commit 9cea32c

Please sign in to comment.