multi configs seem to work now
This commit is contained in:
parent
445ba1fe1f
commit
e86793bfdd
1 changed files with 24 additions and 8 deletions
|
@ -245,7 +245,7 @@ impl Refractr {
|
||||||
let r = running.clone();
|
let r = running.clone();
|
||||||
let count = repos.len();
|
let count = repos.len();
|
||||||
for i in 0..repos.len() {
|
for i in 0..repos.len() {
|
||||||
current_ints.push(u64::from(
|
current_ints.push(i64::from(
|
||||||
repos[i].cfg.schedule.interval.unwrap().unsigned_abs(),
|
repos[i].cfg.schedule.interval.unwrap().unsigned_abs(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -257,11 +257,11 @@ impl Refractr {
|
||||||
.expect("Failed to set ^C handler");
|
.expect("Failed to set ^C handler");
|
||||||
|
|
||||||
common::verbose(self.verbose, 1, format!("Starting scheduled loop"));
|
common::verbose(self.verbose, 1, format!("Starting scheduled loop"));
|
||||||
let min = *current_ints.iter().min().unwrap();
|
|
||||||
let mut do_break = false;
|
let mut do_break = false;
|
||||||
while !do_break {
|
while !do_break {
|
||||||
do_break = true;
|
do_break = true;
|
||||||
let sleep_int = time::Duration::from_secs(min);
|
let min = *current_ints.iter().min().unwrap();
|
||||||
|
let sleep_int = time::Duration::from_secs(min as u64);
|
||||||
let now = time::Instant::now();
|
let now = time::Instant::now();
|
||||||
|
|
||||||
common::verbose(
|
common::verbose(
|
||||||
|
@ -270,13 +270,18 @@ impl Refractr {
|
||||||
format!("Sleeping for {} seconds", sleep_int.as_secs()),
|
format!("Sleeping for {} seconds", sleep_int.as_secs()),
|
||||||
);
|
);
|
||||||
while running.load(Ordering::SeqCst) {
|
while running.load(Ordering::SeqCst) {
|
||||||
thread::sleep(time::Duration::from_secs(1));
|
thread::sleep(time::Duration::from_millis(200));
|
||||||
if now.elapsed().as_secs() >= sleep_int.as_secs() {
|
if now.elapsed().as_secs() >= sleep_int.as_secs() {
|
||||||
common::verbose(self.verbose, 3, format!("Thread has awoken!"));
|
common::verbose(self.verbose, 3, format!("Thread has awoken!"));
|
||||||
for i in 0..count {
|
for i in 0..count {
|
||||||
current_ints[i] -= now.elapsed().as_secs();
|
current_ints[i] -= now.elapsed().as_secs() as i64;
|
||||||
if i <= 0 {
|
common::verbose(
|
||||||
current_ints[i] = original_ints[i].clone();
|
self.verbose,
|
||||||
|
4,
|
||||||
|
format!("checking repo: {}", repos[i].cfg.from),
|
||||||
|
);
|
||||||
|
if current_ints[i] <= 0 {
|
||||||
|
common::verbose(self.verbose, 4, format!("repo is ready for push"));
|
||||||
common::verbose(
|
common::verbose(
|
||||||
self.verbose,
|
self.verbose,
|
||||||
2,
|
2,
|
||||||
|
@ -287,7 +292,13 @@ impl Refractr {
|
||||||
if let Err(e) = self.push_remotes(&repos[i].cfg, &repos[i].repo, &repos[i].remotes) {
|
if let Err(e) = self.push_remotes(&repos[i].cfg, &repos[i].repo, &repos[i].remotes) {
|
||||||
common::error(e, ExitCode::PushError)
|
common::error(e, ExitCode::PushError)
|
||||||
};
|
};
|
||||||
|
current_ints[i] = original_ints[i].clone();
|
||||||
}
|
}
|
||||||
|
common::verbose(
|
||||||
|
self.verbose,
|
||||||
|
4,
|
||||||
|
format!("repo remaining time is now {}", current_ints[i]),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
do_break = false;
|
do_break = false;
|
||||||
break;
|
break;
|
||||||
|
@ -403,7 +414,12 @@ impl Refractr {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
self.set_up_refs(&repo, &cfg.config.branches).unwrap();
|
if let Err(e) = self.set_up_refs(&repo, &cfg.config.branches) {
|
||||||
|
common::error(
|
||||||
|
format!("failed to set up refs: {}", e),
|
||||||
|
ExitCode::RepositoryError,
|
||||||
|
);
|
||||||
|
}
|
||||||
if let Err(e) = self.fetch(
|
if let Err(e) = self.fetch(
|
||||||
&repo,
|
&repo,
|
||||||
&cfg.config.branches,
|
&cfg.config.branches,
|
||||||
|
|
Loading…
Add table
Reference in a new issue