Skip to content

Commit

Permalink
chore(llama-cpp-server): add timeout and retry delay for llama-server…
Browse files Browse the repository at this point in the history
… health check (#3369)
  • Loading branch information
wsxiaoys authored Nov 5, 2024
1 parent 44d65fb commit 27f45f9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/llama-cpp-server/src/supervisor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{env::var, net::TcpListener, process::Stdio};
use std::{env::var, net::TcpListener, process::Stdio, time::Duration};

use tokio::{io::AsyncBufReadExt, task::JoinHandle};
use tracing::{debug, warn};
Expand Down Expand Up @@ -126,7 +126,14 @@ impl LlamaCppSupervisor {
debug!("Waiting for llama-server <{}> to start...", self.name);
let client = reqwest::Client::builder().no_proxy().build().unwrap();
loop {
let Ok(resp) = client.get(api_endpoint(self.port) + "/health").send().await else {
let Ok(resp) = client
.get(api_endpoint(self.port) + "/health")
.timeout(Duration::from_secs(1))
.send()
.await
else {
debug!("llama-server <{}> not ready yet, retrying...", self.name);
tokio::time::sleep(Duration::from_secs(1)).await;
continue;
};

Expand Down

0 comments on commit 27f45f9

Please sign in to comment.