diff --git a/src/tts_download_job.rs b/src/tts_download_job.rs index b3194aac7f..838355823e 100644 --- a/src/tts_download_job.rs +++ b/src/tts_download_job.rs @@ -38,6 +38,7 @@ use crate::util::buckets::bucket_path_unifier::BucketPathUnifier; use crate::util::buckets::bucket_paths::hash_to_bucket_path; use crate::util::filesystem::{check_directory_exists, check_file_exists}; use crate::util::hashing::hash_file_sha2::hash_file_sha2; +use crate::util::noop_logger::NoOpLogger; use crate::util::random_crockford_token::random_crockford_token; use data_encoding::{HEXUPPER, HEXLOWER, HEXLOWER_PERMISSIVE}; use log::{warn, info}; @@ -84,6 +85,9 @@ struct Downloader { // Sleep between batches pub job_batch_wait_millis: u64, + // How long to wait between log lines + pub no_op_logger_millis: u64, + // Max job attempts before failure. // NB: This is an i32 so we don't need to convert to db column type. pub job_max_attempts: i32, @@ -177,6 +181,7 @@ async fn main() -> AnyhowResult<()> { tts_check: tts_model_check_command, job_batch_wait_millis: common_env.job_batch_wait_millis, job_max_attempts: common_env.job_max_attempts as i32, + no_op_logger_millis: common_env.no_op_logger_millis, }; main_loop(downloader).await; @@ -190,6 +195,8 @@ const INCREASE_TIMEOUT_MILLIS : u64 = 1000; async fn main_loop(downloader: Downloader) { let mut error_timeout_millis = START_TIMEOUT_MILLIS; + let mut noop_logger = NoOpLogger::new(downloader.no_op_logger_millis as i64); + loop { let num_records = 1; let query_result = query_tts_upload_job_records(&downloader.mysql_pool, num_records).await; @@ -205,7 +212,8 @@ async fn main_loop(downloader: Downloader) { }; if jobs.is_empty() { - info!("No jobs!"); + noop_logger.log_after_awhile(); + std::thread::sleep(Duration::from_millis(downloader.job_batch_wait_millis)); continue; } diff --git a/src/w2l_download_job.rs b/src/w2l_download_job.rs index bcc2028fb8..243a9a809e 100644 --- a/src/w2l_download_job.rs +++ b/src/w2l_download_job.rs @@ -41,6 +41,7 @@ use crate::util::buckets::bucket_paths::hash_to_bucket_path; use crate::util::filesystem::check_directory_exists; use crate::util::filesystem::check_file_exists; use crate::util::hashing::hash_file_sha2::hash_file_sha2; +use crate::util::noop_logger::NoOpLogger; use crate::util::random_crockford_token::random_crockford_token; use data_encoding::{HEXUPPER, HEXLOWER, HEXLOWER_PERMISSIVE}; use log::{warn, info}; @@ -106,6 +107,9 @@ struct Downloader { // Sleep between batches pub job_batch_wait_millis: u64, + // How long to wait between log lines + pub no_op_logger_millis: u64, + // Max job attempts before failure. // NB: This is an i32 so we don't need to convert to db column type. pub job_max_attempts: i32, @@ -222,6 +226,7 @@ async fn main() -> AnyhowResult<()> { debug_job_end_sleep_millis: easyenv::get_env_num("DEBUG_JOB_END_SLEEP_MILLIS", 0)?, job_batch_wait_millis: common_env.job_batch_wait_millis, job_max_attempts: common_env.job_max_attempts as i32, + no_op_logger_millis: common_env.no_op_logger_millis, }; main_loop(downloader).await; @@ -235,6 +240,8 @@ const INCREASE_TIMEOUT_MILLIS : u64 = 1000; async fn main_loop(downloader: Downloader) { let mut error_timeout_millis = START_TIMEOUT_MILLIS; + let mut noop_logger = NoOpLogger::new(downloader.no_op_logger_millis as i64); + loop { let num_records = 1; @@ -254,7 +261,8 @@ async fn main_loop(downloader: Downloader) { }; if jobs.is_empty() { - info!("No jobs!"); + noop_logger.log_after_awhile(); + std::thread::sleep(Duration::from_millis(downloader.job_batch_wait_millis)); continue; } diff --git a/src/w2l_inference_job.rs b/src/w2l_inference_job.rs index 55ed7d4a70..2b0148358e 100644 --- a/src/w2l_inference_job.rs +++ b/src/w2l_inference_job.rs @@ -42,6 +42,7 @@ use crate::util::buckets::bucket_paths::hash_to_bucket_path; use crate::util::filesystem::check_directory_exists; use crate::util::filesystem::check_file_exists; use crate::util::hashing::hash_file_sha2::hash_file_sha2; +use crate::util::noop_logger::NoOpLogger; use crate::util::random_crockford_token::random_crockford_token; use crate::util::semi_persistent_cache_dir::SemiPersistentCacheDir; use data_encoding::{HEXUPPER, HEXLOWER, HEXLOWER_PERMISSIVE}; @@ -103,6 +104,9 @@ struct Inferencer { // Sleep between batches pub job_batch_wait_millis: u64, + // How long to wait between log lines + pub no_op_logger_millis: u64, + // Max job attempts before failure. // NB: This is an i32 so we don't need to convert to db column type. pub job_max_attempts: i32, @@ -230,6 +234,7 @@ async fn main() -> AnyhowResult<()> { w2l_end_bump_filename, job_batch_wait_millis: common_env.job_batch_wait_millis, job_max_attempts: common_env.job_max_attempts as i32, + no_op_logger_millis: common_env.no_op_logger_millis, }; main_loop(inferencer).await; @@ -243,6 +248,8 @@ const INCREASE_TIMEOUT_MILLIS : u64 = 1000; async fn main_loop(inferencer: Inferencer) { let mut error_timeout_millis = START_TIMEOUT_MILLIS; + let mut noop_logger = NoOpLogger::new(inferencer.no_op_logger_millis as i64); + loop { let num_records = 1; @@ -262,7 +269,8 @@ async fn main_loop(inferencer: Inferencer) { }; if jobs.is_empty() { - info!("No jobs!"); + noop_logger.log_after_awhile(); + std::thread::sleep(Duration::from_millis(inferencer.job_batch_wait_millis)); continue; }