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

@ -262,7 +262,7 @@ impl Default for ServerConfig {
verbose_stats: true,
stats_endpoint: "/stats".to_string(),
enable_stats_endpoint: true,
enable_stats_endpoint: false,
non_ws_response: ":3".to_string(),

View file

@ -338,11 +338,7 @@ impl ServerListener {
SocketType::TlsUnix => {
Self::TlsUnix(Self::bind_unix().await?, Self::create_tls().await?)
}
SocketType::File => {
Self::File(Some(PathBuf::try_from(&CONFIG.server.bind).with_context(
|| format!("failed to parse path `{}` for file", CONFIG.server.bind),
)?))
}
SocketType::File => Self::File(Some(CONFIG.server.bind.clone().into())),
})
}

View file

@ -200,7 +200,9 @@ async fn main() -> anyhow::Result<()> {
let mut listener = ServerListener::new().await?;
loop {
let (stream, id) = listener.accept().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;
@ -209,4 +211,7 @@ async fn main() -> anyhow::Result<()> {
}
});
}
Err(e) => error!("error while accepting client: {:?}", e),
}
}
}