1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 15:29:21 +00:00

Add initial clean interval

This commit is contained in:
Pierre HUBERT 2021-02-14 18:54:39 +01:00
parent a537dbcd4d
commit 2dbf7ee850
2 changed files with 7 additions and 1 deletions

View File

@ -4,7 +4,7 @@
//! //!
//! @author Pierre Hubert //! @author Pierre Hubert
use crate::constants::CLEAN_UP_INTERVAL; use crate::constants::{CLEAN_UP_INTERVAL, INITIAL_REFRESH_LOAD_INTERVAL};
use crate::data::error::Res; use crate::data::error::Res;
use crate::helpers::{account_helper, comments_helper, likes_helper, notifications_helper, user_helper}; use crate::helpers::{account_helper, comments_helper, likes_helper, notifications_helper, user_helper};
@ -16,6 +16,9 @@ pub fn start() -> Res {
/// Clean up thread handler /// Clean up thread handler
fn clean_up_thread_handler() { fn clean_up_thread_handler() {
// Let the server start before doing cleanup
std::thread::sleep(INITIAL_REFRESH_LOAD_INTERVAL);
loop { loop {
println!("Start clean up operation"); println!("Start clean up operation");
match do_clean() { match do_clean() {

View File

@ -113,5 +113,8 @@ pub const USER_LAST_ACTIVITY_REFRESH: Duration = Duration::from_secs(60);
/// Interval at which last activity of an access token should be recorded /// Interval at which last activity of an access token should be recorded
pub const USER_ACCESS_TOKEN_ACTIVITY_REFRESH: Duration = Duration::from_secs(60 * 60); pub const USER_ACCESS_TOKEN_ACTIVITY_REFRESH: Duration = Duration::from_secs(60 * 60);
/// Sleep time before initial clean up execution
pub const INITIAL_REFRESH_LOAD_INTERVAL: Duration = Duration::from_secs(5);
/// Interval between each cleanup operation (every hour) /// Interval between each cleanup operation (every hour)
pub const CLEAN_UP_INTERVAL: Duration = Duration::from_secs(60 * 60); pub const CLEAN_UP_INTERVAL: Duration = Duration::from_secs(60 * 60);