Wait for service fn simplification

This commit is contained in:
Filip Znachor 2023-08-04 00:11:27 +02:00
parent 161a006ebe
commit 912871f833

View file

@ -90,26 +90,19 @@ fn stop_service(name: &String) {
}
async fn wait_for_service(proxy: &ProxyConf) {
if proxy.socket {
let path = Path::new(&proxy.target);
while !path.exists() {
sleep(Duration::from_millis(100)).await;
}
} else {
if let Some(address) = target_to_address(&proxy.target) {
loop {
sleep(Duration::from_millis(100)).await;
match TcpStream::connect(address) {
Ok(_) => break,
Err(_) => {}
}
}
}
}
if proxy.socket {
let path = Path::new(&proxy.target);
while !path.exists() {
sleep(Duration::from_millis(100)).await;
}
} else {
while target_to_address(&proxy.target)
.map(|address| TcpStream::connect(address).is_err())
.unwrap_or(true)
{
sleep(Duration::from_millis(100)).await;
}
}
}
pub async fn prepare_services() {