Remove panics

This commit is contained in:
Tristan D. 2025-03-18 00:55:37 +01:00
parent 4861b479a7
commit 75d19433be
Signed by: tristan
SSH key fingerprint: SHA256:9oFM1J63hYWJjCnLG6C0fxBS15rwNcWwdQNMOHYKJ/4
3 changed files with 13 additions and 10 deletions

View file

@ -98,7 +98,7 @@ async fn main() -> anyhow::Result<()> {
let proxy_man_fut = async move { let proxy_man_fut = async move {
use llama_proxy_man::{config::AppConfig, start_server}; use llama_proxy_man::{config::AppConfig, start_server};
let config = AppConfig::default_figment(); let config = AppConfig::default_figment();
start_server(config).await; start_server(config).await?;
Ok::<(), anyhow::Error>(()) Ok::<(), anyhow::Error>(())
}; };

View file

@ -51,7 +51,7 @@ pub fn axum_router(spec: &ModelSpec, state: AppState) -> Router {
} }
/// Starts an inference server for each model defined in the config. /// Starts an inference server for each model defined in the config.
pub async fn start_server(config: AppConfig) { pub async fn start_server(config: AppConfig) -> anyhow::Result<()> {
let state = AppState::from_config(config.clone()); let state = AppState::from_config(config.clone());
let mut handles = Vec::new(); let mut handles = Vec::new();
@ -59,17 +59,17 @@ pub async fn start_server(config: AppConfig) {
let state = state.clone(); let state = state.clone();
let spec = spec.clone(); let spec = spec.clone();
let handle = tokio::spawn(async move { let handle: tokio::task::JoinHandle<anyhow::Result<()>> = tokio::spawn(async move {
let app = axum_router(&spec, state); let app = axum_router(&spec, state);
let addr = SocketAddr::from(([0, 0, 0, 0], spec.port)); let addr = SocketAddr::from(([0, 0, 0, 0], spec.port));
tracing::info!(msg = "Listening", ?spec); tracing::info!(msg = "Listening", ?spec);
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap(); let listener = tokio::net::TcpListener::bind(&addr).await?;
axum::serve(listener, app.into_make_service()) axum::serve(listener, app.into_make_service()).await?;
.await Ok(())
.unwrap();
}); });
handles.push(handle); handles.push(handle);
} }
futures::future::join_all(handles).await; let _ = futures::future::try_join_all(handles).await?;
Ok(())
} }

View file

@ -1,10 +1,13 @@
use anyhow;
use llama_proxy_man::{config::AppConfig, logging, start_server}; use llama_proxy_man::{config::AppConfig, logging, start_server};
#[tokio::main] #[tokio::main]
async fn main() { async fn main() -> anyhow::Result<()> {
logging::initialize_logger(); logging::initialize_logger();
let config = AppConfig::default_from_pwd_yml(); let config = AppConfig::default_from_pwd_yml();
start_server(config).await; start_server(config).await?;
Ok(())
} }