Skip to content

Commit

Permalink
Add health endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmbmb committed Sep 4, 2024
1 parent 4470305 commit 23173cc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion candle-holder-serve/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod routes;
mod workers;

use anyhow::Result;
use axum::routing::get;
use axum::Router;
use clap::Parser;

Expand All @@ -32,11 +33,17 @@ async fn main() -> Result<()> {
Pipeline::TokenClassification => token_classification::router(&args)?,
Pipeline::ZeroShotClassification => zero_shot_classification::router(&args)?,
};
let router = Router::new().nest("/", inference_router);
let router = Router::new()
.nest("/", inference_router)
.route("/health", get(health));

tracing::info!("Listening on {}", args.host());
let listener = tokio::net::TcpListener::bind(args.host()).await.unwrap();
axum::serve(listener, router).await.unwrap();

Ok(())
}

async fn health() -> &'static str {
"OK"
}

0 comments on commit 23173cc

Please # to comment.