From 9fb8d44bf850dc398714d101f061e5f1c27647a0 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Mon, 19 Aug 2024 21:11:08 +0200 Subject: fs-tracer: handle exit in restore file thread --- fs-tracer/src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs-tracer/src/main.rs b/fs-tracer/src/main.rs index ba52ff3..2616ac9 100644 --- a/fs-tracer/src/main.rs +++ b/fs-tracer/src/main.rs @@ -113,8 +113,14 @@ async fn main() -> Result<(), anyhow::Error> { //TODO: Create thread getting restored files every X secs and actually restore them let thread_api_key = fs_tracer_api_key.clone(); + let thread_exit = exit.clone(); tokio::spawn(async move { loop { + if thread_exit.load(Ordering::Relaxed) { + info!("STOPPED THREAD, RETURNING"); + return; + } + println!("Getting files to restore"); let resp = ureq::get(&format!("http://leunam.dev:9999/api/v1/restored-files/")) .set("API_KEY", &thread_api_key) .call() @@ -143,7 +149,7 @@ async fn main() -> Result<(), anyhow::Error> { } } - std::thread::sleep(Duration::from_secs(20)); + std::thread::sleep(Duration::from_secs(2)); } }); -- cgit 1.4.1