remove existing unix socket if it exists

This commit is contained in:
Toshit Chawda 2024-03-09 14:32:33 -08:00
parent bc52ea54f3
commit 55d40aa32d

View file

@ -80,6 +80,10 @@ impl Listener {
async fn bind(addr: &str, unix: bool) -> Result<Listener, std::io::Error> { async fn bind(addr: &str, unix: bool) -> Result<Listener, std::io::Error> {
#[cfg(unix)] #[cfg(unix)]
if 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)?)); return Ok(Listener::Unix(UnixListener::bind(addr)?));
} }
#[cfg(not(unix))] #[cfg(not(unix))]