Compare commits

...

2 commits

Author SHA1 Message Date
Filip Znachor d34159b4b6 Improved README 2023-08-04 00:11:36 +02:00
Filip Znachor 912871f833 Wait for service fn simplification 2023-08-04 00:11:27 +02:00
2 changed files with 28 additions and 21 deletions

16
README.md Normal file → Executable file
View file

@ -1,3 +1,17 @@
# odproxy
Simple HTTP reverse proxy that dynamically manages backend services based on demand.
Simple HTTP reverse proxy that dynamically manages backend services based on demand.
Find yourself ever in a situation where you don't have a lot of resources and you run a lot of different services on your server that nobody uses most of the time? Then odproxy is for you!
## Features
- configurable **listening address** and **port**
- **multiple** configured **hosts** with **multiple hostnames**
- automatic process **spawning** based on demand
- **logging** cases of **unknown hostnames**
### In future releases
- listening on socket
- start and stop command mode

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() {