This commit is contained in:
jmb05
2026-11-02 17:26:51 +01:00
parent cdfc5b8d36
commit 11fb03427c
7 changed files with 94 additions and 94 deletions

View File

@@ -6,6 +6,7 @@ use jmb_logger_rs::*;
use std::io::Read;
use std::net::Shutdown;
use std::os::unix::net::UnixListener;
use std::str::FromStr;
use std::sync::{Arc, Mutex};
pub struct ControlSocket {
@@ -34,11 +35,11 @@ impl SimpleBackendThread<ControlCommand> for ControlSocket {
}
});
std::thread::spawn(move || {
if std::fs::metadata(SOCKET_PATH).is_ok() {
if let Err(e) = std::fs::remove_file(SOCKET_PATH) {
error!(&LOGGER, "Error deleting old socket file: {e}");
return;
}
if std::fs::metadata(SOCKET_PATH).is_ok()
&& let Err(e) = std::fs::remove_file(SOCKET_PATH)
{
error!(&LOGGER, "Error deleting old socket file: {e}");
return;
}
let socket = UnixListener::bind(SOCKET_PATH);
let Ok(socket) = socket else {
@@ -58,7 +59,7 @@ impl SimpleBackendThread<ControlCommand> for ControlSocket {
let _ = stream.shutdown(Shutdown::Both);
continue;
}
if let Some(command) = ControlCommand::from_str(&read) {
if let Ok(command) = ControlCommand::from_str(&read) {
instance.lock().unwrap().publish(command);
}
}