Skip to content

Commit

Permalink
rename /health/live to /health/model and have /health/live just check…
Browse files Browse the repository at this point in the history
… canEnqueueRequests
  • Loading branch information
mmoskal committed Nov 25, 2024
1 parent 5b6d7d6 commit a4f0aec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions llgtrt/src/async_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ impl AsyncExecutor {
Ok((res, tok_env, chat_builder))
}

pub fn can_enqueue_request(&self) -> bool {
self.executor.can_enqueue_request()
}

pub fn add_request(
&mut self,
init: RequestInit,
Expand Down
15 changes: 13 additions & 2 deletions llgtrt/src/routes/health_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use axum::{
use serde_json::{json, Value};

use crate::{
async_exec::AsyncExecutor,
error::AppError,
routes::{completions, openai::CompletionCreateParams},
state::AppState,
Expand All @@ -18,7 +19,18 @@ pub async fn ready_check() {
log::info!("ready_check -> all good");
}

pub async fn live_check(
pub async fn live_check() -> Result<Response, AppError> {
let can_enq = AsyncExecutor::lock().can_enqueue_request();
if can_enq {
log::info!("live_check -> all good");
Ok((StatusCode::OK, "Check complete").into_response())
} else {
log::error!("live_check -> failed");
Ok((StatusCode::INTERNAL_SERVER_ERROR, "Check failed").into_response())
}
}

pub async fn model_check(
headers: HeaderMap,
State(app_state): State<Arc<AppState>>,
) -> Result<Response, AppError> {
Expand Down Expand Up @@ -46,7 +58,6 @@ pub async fn live_check(
);
Ok((StatusCode::INTERNAL_SERVER_ERROR, "Check failed").into_response())
}

} else {
log::error!(
"Liveness check failed with status code: {}; body {}",
Expand Down
1 change: 1 addition & 0 deletions llgtrt/src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ pub async fn run_server(mut cli_config: CliConfig) -> anyhow::Result<()> {
.route("/v1/completions", post(routes::route_completions))
.route("/v1/chat/completions", post(routes::route_chat_completions))
.route("/v1/health/live", get(routes::live_check))
.route("/v1/health/model", get(routes::model_check))
.route("/v1/health/ready", get(routes::ready_check))
.route("/v1/run", post(routes::route_llguidance))
.route("/guidance", post(routes::route_llguidance))
Expand Down

0 comments on commit a4f0aec

Please sign in to comment.