Wait for sbot is working
continuous-integration/drone/pr Build is failing
Details
continuous-integration/drone/pr Build is failing
Details
This commit is contained in:
parent
cb09d6c3e9
commit
29f5ad0e84
|
@ -2200,7 +2200,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "peach-config"
|
name = "peach-config"
|
||||||
version = "0.1.26"
|
version = "0.1.27"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"clap",
|
"clap",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "peach-config"
|
name = "peach-config"
|
||||||
version = "0.1.26"
|
version = "0.1.27"
|
||||||
authors = ["Andrew Reid <gnomad@cryptolab.net>", "Max Fowler <max@mfowler.info>"]
|
authors = ["Andrew Reid <gnomad@cryptolab.net>", "Max Fowler <max@mfowler.info>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Command line tool for installing, updating and configuring PeachCloud"
|
description = "Command line tool for installing, updating and configuring PeachCloud"
|
||||||
|
|
|
@ -200,7 +200,9 @@ async fn run() {
|
||||||
},
|
},
|
||||||
PeachConfig::WaitForSbot => {
|
PeachConfig::WaitForSbot => {
|
||||||
match wait_for_sbot::wait_for_sbot().await {
|
match wait_for_sbot::wait_for_sbot().await {
|
||||||
Ok(_) => {}
|
Ok(sbot_id) => {
|
||||||
|
println!("connected with sbot and found sbot_id: {:?}", sbot_id)
|
||||||
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(
|
error!(
|
||||||
"peach-config did not successfully connect to sbot: {}",
|
"peach-config did not successfully connect to sbot: {}",
|
||||||
|
|
|
@ -5,11 +5,11 @@ use peach_lib::sbot::init_sbot;
|
||||||
|
|
||||||
/// Utility function to wait for a successful whoami call with sbot
|
/// Utility function to wait for a successful whoami call with sbot
|
||||||
/// After each attempt to call whoami it waits 2 seconds,
|
/// After each attempt to call whoami it waits 2 seconds,
|
||||||
/// and if after max_num_attempts (8) there is no successful whoami call
|
/// and if after max_num_attempts (10) there is no successful whoami call
|
||||||
/// it returns an Error. Otherwise it returns Ok(sbot_id).
|
/// it returns an Error. Otherwise it returns Ok(sbot_id).
|
||||||
pub async fn wait_for_sbot() -> Result<String, PeachConfigError> {
|
pub async fn wait_for_sbot() -> Result<String, PeachConfigError> {
|
||||||
let mut num_attempts = 0;
|
let mut num_attempts = 0;
|
||||||
let max_num_attempts = 8;
|
let max_num_attempts = 10;
|
||||||
let mut sbot_is_running = 0;
|
let mut sbot_is_running = 0;
|
||||||
let mut whoami = None;
|
let mut whoami = None;
|
||||||
while (sbot_is_running == 0) & (num_attempts < max_num_attempts) {
|
while (sbot_is_running == 0) & (num_attempts < max_num_attempts) {
|
||||||
|
@ -32,10 +32,11 @@ pub async fn wait_for_sbot() -> Result<String, PeachConfigError> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if sbot_is_running == 0 {
|
if sbot_is_running == 0 {
|
||||||
|
println!("trying again {:?}", num_attempts);
|
||||||
num_attempts += 1;
|
num_attempts += 1;
|
||||||
let two_seconds = time::Duration::from_secs(2);
|
let two_seconds = time::Duration::from_secs(2);
|
||||||
thread::sleep(two_seconds);
|
thread::sleep(two_seconds);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
whoami.ok_or(PeachConfigError::WaitForSbotError{ message: "Failed to find sbot_id".to_string()})
|
whoami.ok_or(PeachConfigError::WaitForSbotError{ message: "Failed to find sbot_id after 10 attempts".to_string()})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue