feat: ability to disable backup thread
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/clippy Pipeline failed Details
ci/woodpecker/push/build Pipeline was successful Details

signal-handling
Jef Roosens 2023-06-04 08:57:31 +02:00
parent 3c5cdaef4f
commit f083d7e701
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 6 additions and 4 deletions

View File

@ -39,8 +39,8 @@ struct Cli {
/// How many backups to keep
#[arg(short = 'n', long, default_value_t = 7)]
max_backups: u64,
/// How frequently to perform a backup, in minutes
#[arg(short = 't', long, default_value_t = 720)]
/// How frequently to perform a backup, in minutes; 0 to disable.
#[arg(short = 't', long, default_value_t = 0)]
frequency: u64,
}
@ -69,8 +69,10 @@ fn main() {
.max_backups(cli.max_backups);
let counter = Arc::new(Mutex::new(cmd.spawn().expect("Failed to start server.")));
if cli.frequency > 0 {
let clone = Arc::clone(&counter);
std::thread::spawn(move || backups_thread(clone, cli.frequency));
}
let stdin = io::stdin();
let input = &mut String::new();