diff --git a/src/server/command_socket.rs b/src/server/command_socket.rs
index 7378ed8e..07ee5fe1 100644
--- a/src/server/command_socket.rs
+++ b/src/server/command_socket.rs
@@ -13,18 +13,20 @@ use serde_json::Value;
use std::sync::Arc;
/// Listens on a Unix Socket to handle simple command asynchronously
-pub fn create_control_socket
(path: P, f: F) -> Result, Error>
+pub fn create_control_socket(path: P, auto_remove: bool, f: F) -> Result, Error>
where P: Into,
F: Send + Sync +'static + Fn(Value) -> Result,
{
let path: PathBuf = path.into();
+ let path1: PathBuf = path.clone();
+
+ if auto_remove { let _ = std::fs::remove_file(&path); }
let socket = UnixListener::bind(&path)?;
let f = Arc::new(f);
- let path = Arc::new(path);
- let path2 = path.clone();
- let path3 = path.clone();
+ let path2 = Arc::new(path);
+ let path3 = path2.clone();
let control_future = socket.incoming()
.map_err(move |err| { eprintln!("failed to accept on control socket {:?}: {}", path2, err); })
@@ -61,7 +63,12 @@ pub fn create_control_socket(path: P, f: F) -> Result