Remove panics
This commit is contained in:
parent
4861b479a7
commit
75d19433be
3 changed files with 13 additions and 10 deletions
|
@ -98,7 +98,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
let proxy_man_fut = async move {
|
||||
use llama_proxy_man::{config::AppConfig, start_server};
|
||||
let config = AppConfig::default_figment();
|
||||
start_server(config).await;
|
||||
start_server(config).await?;
|
||||
|
||||
Ok::<(), anyhow::Error>(())
|
||||
};
|
||||
|
|
|
@ -51,7 +51,7 @@ pub fn axum_router(spec: &ModelSpec, state: AppState) -> Router {
|
|||
}
|
||||
|
||||
/// 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 mut handles = Vec::new();
|
||||
|
@ -59,17 +59,17 @@ pub async fn start_server(config: AppConfig) {
|
|||
let state = state.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 addr = SocketAddr::from(([0, 0, 0, 0], spec.port));
|
||||
tracing::info!(msg = "Listening", ?spec);
|
||||
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
|
||||
axum::serve(listener, app.into_make_service())
|
||||
.await
|
||||
.unwrap();
|
||||
let listener = tokio::net::TcpListener::bind(&addr).await?;
|
||||
axum::serve(listener, app.into_make_service()).await?;
|
||||
Ok(())
|
||||
});
|
||||
handles.push(handle);
|
||||
}
|
||||
|
||||
futures::future::join_all(handles).await;
|
||||
let _ = futures::future::try_join_all(handles).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
use anyhow;
|
||||
use llama_proxy_man::{config::AppConfig, logging, start_server};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
logging::initialize_logger();
|
||||
|
||||
let config = AppConfig::default_from_pwd_yml();
|
||||
|
||||
start_server(config).await;
|
||||
start_server(config).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue