Skip to content

Commit

Permalink
opt: config add cronjob
Browse files Browse the repository at this point in the history
  • Loading branch information
kulukami committed Feb 23, 2024
1 parent 6dc2c53 commit 01f0044
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions plugins/scanner/settings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ log_level = "info"
log_path = "./"
remote_log_level = "error"
max_backups = 10
enable_cronjob = 0

[engine]
clamav_max_filesize = 18874368
Expand Down
12 changes: 7 additions & 5 deletions plugins/scanner/src/bin/scanner_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use scanner::{
ARCHIVE_DB_HASH, ARCHIVE_DB_PWD, ARCHIVE_DB_VERSION, DB_DEFAULT, DB_URLS,
SERVICE_DEFAULT_CG_CPU, SERVICE_DEFAULT_CG_MEM, SERVICE_DEFAULT_LOG_LEVEL,
SERVICE_DEFAULT_LOG_MAX_BAK, SERVICE_DEFAULT_LOG_PATH, SERVICE_DEFAULT_LOG_RLEVEL,
SERVICE_PID_LOCK_PATH,
SERVICE_ENABLE_CRONJOB, SERVICE_PID_LOCK_PATH,
},
detector::Detector,
model::engine::clamav::{self, updater},
Expand Down Expand Up @@ -153,10 +153,12 @@ fn main() {
});

// cronjob scan dir and proc
let s_cron_worker = s.clone();
let s_cron_lock = s_lock.clone();
let _cronjob_t = Cronjob::new(s_cron_worker, s_cron_lock, WAIT_INTERVAL_DAILY);

let mut _cronjob_t = None;
if *SERVICE_ENABLE_CRONJOB != 0{
let s_cron_worker = s.clone();
let s_cron_lock = s_lock.clone();
_cronjob_t = Some(Cronjob::new(s_cron_worker, s_cron_lock, WAIT_INTERVAL_DAILY));
}
// wait childs
let _: () = r_lock.recv().unwrap();

Expand Down
1 change: 1 addition & 0 deletions plugins/scanner/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ lazy_static::lazy_static!(
pub static ref SERVICE_DEFAULT_LOG_PATH: String = settings_string("service","log_path").unwrap().to_string();
pub static ref SERVICE_DEFAULT_LOG_RLEVEL: String = settings_string("service","remote_log_level").unwrap().to_string();
pub static ref SERVICE_DEFAULT_LOG_MAX_BAK: i64 = settings_int("service","max_backups").unwrap() as _;
pub static ref SERVICE_ENABLE_CRONJOB: i64 = settings_int("service","enable_cronjob").unwrap() as _;

pub static ref SCAN_DIR_CONFIG: Vec<ScanConfigs> = gen_scan_dir().unwrap();
pub static ref SCAN_DIR_FILTER: Vec<String> = settings_vec_string("scan","filter").unwrap();
Expand Down

0 comments on commit 01f0044

Please sign in to comment.