make accept errors nonfatal, fixes #6, also default to stats endpoint off

This commit is contained in:
Toshit Chawda 2024-09-19 16:04:46 -07:00
parent 7fdacb2623
commit f798b5544e
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
3 changed files with 13 additions and 12 deletions

View file

@ -200,13 +200,18 @@ async fn main() -> anyhow::Result<()> {
let mut listener = ServerListener::new().await?;
loop {
let (stream, id) = listener.accept().await?;
tokio::spawn(async move {
let res = route::route(stream, move |stream| handle_stream(stream, id)).await;
let ret = listener.accept().await;
match ret {
Ok((stream, id)) => {
tokio::spawn(async move {
let res = route::route(stream, move |stream| handle_stream(stream, id)).await;
if let Err(e) = res {
error!("error while routing client: {:?}", e);
if let Err(e) = res {
error!("error while routing client: {:?}", e);
}
});
}
});
Err(e) => error!("error while accepting client: {:?}", e),
}
}
}