Skip to content

Commit

Permalink
fix: retention cleanup on server startup (#662)
Browse files Browse the repository at this point in the history
fixes #660
  • Loading branch information
gurjotkaur20 authored Feb 18, 2024
1 parent 121bf01 commit c6e3b14
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/src/storage/retention.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,15 @@ pub fn init_scheduler() {
}
};

// Execute once on startup
thread::spawn(move || {
let rt = async_runtime();
rt.block_on(func());
});

scheduler.every(1.day()).at("00:00").run(func);

let handler = thread::spawn(|| {
let scheduler_handler = thread::spawn(|| {
let rt = async_runtime();
rt.block_on(async move {
loop {
Expand All @@ -95,7 +101,7 @@ pub fn init_scheduler() {
});
});

*SCHEDULER_HANDLER.lock().unwrap() = Some(handler);
*SCHEDULER_HANDLER.lock().unwrap() = Some(scheduler_handler);
log::info!("Scheduler is initialized")
}

Expand Down

0 comments on commit c6e3b14

Please sign in to comment.