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

Commit 9cea32c

Browse files
definitelynobodynpmccallum
authored andcommitted
fix: preemptively fix short lived workloads having no output
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 <nicholas@profian.com>
1 parent a07331b commit 9cea32c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,14 @@ async fn root_post(
460460
tokio::spawn(async move {
461461
// Convert from minutes to seconds.
462462
sleep(Duration::from_secs(ctx.timeout * 60)).await;
463+
464+
// Stop running the workload
465+
if let Some(state) = OUT.write().await.get(&uuid) {
466+
let _ = state.lock().await.exec.kill().await;
467+
}
468+
469+
// Remove the workload state completely if it still exists
470+
sleep(Duration::from_secs(5 * 60)).await;
463471
OUT.write().await.remove(&uuid);
464472
});
465473

0 commit comments

Comments
 (0)