From 55d40aa32d097031aded6b6da3b4503ba2b3ca1c Mon Sep 17 00:00:00 2001 From: Toshit Chawda Date: Sat, 9 Mar 2024 14:32:33 -0800 Subject: [PATCH] remove existing unix socket if it exists --- server/src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/main.rs b/server/src/main.rs index 5e80cf7..c0b78e5 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -80,6 +80,10 @@ impl Listener { async fn bind(addr: &str, unix: bool) -> Result { #[cfg(unix)] if unix { + if std::fs::metadata(addr).is_ok() { + println!("attempting to remove old socket {:?}", addr); + std::fs::remove_file(addr)?; + } return Ok(Listener::Unix(UnixListener::bind(addr)?)); } #[cfg(not(unix))]