Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/dfx/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::lib::replica_config::ReplicaConfig;
use clap::{App, Arg, ArgMatches, SubCommand};
use crossbeam::channel::{Receiver, Sender};
use crossbeam::unbounded;
use delay::{Delay, Waiter};
use futures::future::Future;
use ic_agent::{Agent, AgentConfig};
use indicatif::{ProgressBar, ProgressDrawTarget};
Expand Down Expand Up @@ -56,14 +57,24 @@ fn ping_and_wait(frontend_url: &str) -> DfxResult {
})?;

// wait for frontend to come up
use std::{thread, time};
let three_secs = time::Duration::from_secs(3);
thread::sleep(three_secs);

runtime
.block_on(agent.status())
.map(|_| ())
.map_err(DfxError::from)
let mut waiter = Delay::builder()
.timeout(std::time::Duration::from_secs(30))
.throttle(std::time::Duration::from_secs(1))
.build();

runtime.block_on(async {
waiter.start();
loop {
let status = agent.status().await;
if status.is_ok() {
break;
}
waiter
.wait()
.map_err(|_| DfxError::AgentError(status.unwrap_err()))?;
}
Ok(())
})
}

// TODO(eftychis)/In progress: Rename to replica.
Expand Down