diff options
| author | metamuffin <metamuffin@disroot.org> | 2025-11-15 15:55:09 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2025-11-15 15:55:09 +0100 |
| commit | cfe57a5e8f0cb9d76526776d3d274a638b138ea3 (patch) | |
| tree | 49c58d2948f39e7433c139e5e17c6084cdbb6867 | |
| parent | 0468ad9b7b1b48d923bc0d7c4808490446bb8d36 (diff) | |
| download | gnix-cfe57a5e8f0cb9d76526776d3d274a638b138ea3.tar gnix-cfe57a5e8f0cb9d76526776d3d274a638b138ea3.tar.bz2 gnix-cfe57a5e8f0cb9d76526776d3d274a638b138ea3.tar.zst | |
Fix crash on missing old socket
| -rw-r--r-- | src/control_socket.rs | 14 | ||||
| -rw-r--r-- | src/main.rs | 10 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/control_socket.rs b/src/control_socket.rs index 855ec2c..d0fa3b9 100644 --- a/src/control_socket.rs +++ b/src/control_socket.rs @@ -30,12 +30,14 @@ pub enum ControlSocketResponse { } pub async fn serve_control_socket(state: Arc<State>, path: &Path) -> Result<()> { - let meta = path.metadata()?; - // TODO proper check - if !meta.is_dir() && !meta.is_file() && !meta.is_symlink() { - remove_file(path) - .await - .context("removing old control socket")?; + if path.exists() { + let meta = path.metadata().context("metadata of old socket")?; + // TODO proper check + if !meta.is_dir() && !meta.is_file() && !meta.is_symlink() { + remove_file(path) + .await + .context("removing old control socket")?; + } } let listener = UnixListener::bind(path).context("creating control socket")?; diff --git a/src/main.rs b/src/main.rs index 4bb61a7..9a623d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -165,7 +165,7 @@ async fn main() -> anyhow::Result<()> { }) .await { - error!("Config Watch: {e:?}"); + error!("Config Watch: {e:#}"); exit(1) } }); @@ -175,7 +175,7 @@ async fn main() -> anyhow::Result<()> { let state = state.clone(); tokio::spawn(async move { if let Err(e) = serve_control_socket(state, &path).await { - error!("Control Socket: {e:?}"); + error!("Control Socket: {e:#}"); exit(1) } }); @@ -184,7 +184,7 @@ async fn main() -> anyhow::Result<()> { let state = state.clone(); tokio::spawn(async move { if let Err(e) = serve_http(state).await { - error!("HTTP: {e:?}"); + error!("HTTP: {e:#}"); exit(1) } }); @@ -193,7 +193,7 @@ async fn main() -> anyhow::Result<()> { let state = state.clone(); tokio::spawn(async move { if let Err(e) = serve_https(state).await { - error!("HTTPS (h1+h2): {e:?}"); + error!("HTTPS (h1+h2): {e:#}"); exit(1) } }); @@ -202,7 +202,7 @@ async fn main() -> anyhow::Result<()> { let state = state.clone(); tokio::spawn(async move { if let Err(e) = serve_h3(state).await { - error!("HTTPS (h3): {e:?}"); + error!("HTTPS (h3): {e:#}"); exit(1) } }); |