fix: make the startup path more robust

This commit is contained in:
Denis Benato
2025-10-06 19:19:31 +02:00
parent 1014f97b6f
commit 84c8babdb7
2 changed files with 49 additions and 15 deletions

View File

@@ -78,14 +78,19 @@ impl AsusArmouryAttribute {
let sig = signal_ctxt.clone(); let sig = signal_ctxt.clone();
tokio::spawn(async move { tokio::spawn(async move {
let mut buffer = [0; 32]; let mut buffer = [0; 32];
watch if let Ok(mut stream) = watch.into_event_stream(&mut buffer) {
.into_event_stream(&mut buffer) stream
.unwrap() .for_each(|_| async {
.for_each(|_| async { debug!("{} changed", name);
debug!("{} changed", name); ctrl.$fn_prop_changed(&sig).await.ok();
ctrl.$fn_prop_changed(&sig).await.ok(); })
}) .await;
.await; } else {
info!(
"inotify event stream failed for {} ({}). You can ignore this if unsupported",
name, $attr_str
);
}
}); });
} }
Err(e) => info!( Err(e) => info!(
@@ -387,13 +392,37 @@ pub async fn start_attributes_zbus(
power.clone(), power.clone(),
config.clone(), config.clone(),
); );
attr.reload().await?;
if let Err(e) = attr.reload().await {
error!(
"Skipping attribute '{}' due to reload error: {e:?}",
attr.attr.name()
);
// continue with others
continue;
}
let path = dbus_path_for_attr(attr.attr.name()); let path = dbus_path_for_attr(attr.attr.name());
let sig = zbus::object_server::SignalEmitter::new(conn, path)?; match zbus::object_server::SignalEmitter::new(conn, path) {
attr.watch_and_notify(sig).await?; Ok(sig) => {
if let Err(e) = attr.watch_and_notify(sig).await {
error!(
"Failed to start watcher for '{}': {e:?}",
attr.attr.name()
);
}
}
Err(e) => {
error!("Failed to create SignalEmitter for '{}': {e:?}", attr.attr.name());
}
}
attr.move_to_zbus(conn).await?; if let Err(e) = attr.move_to_zbus(conn).await {
error!(
"Failed to register attribute '{}' on zbus: {e:?}",
attr.attr.name()
);
}
} }
Ok(()) Ok(())
} }

View File

@@ -62,7 +62,9 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
// Start zbus server // Start zbus server
let mut server = Connection::system().await?; let mut server = Connection::system().await?;
server.object_server().at("/", ObjectManager).await.unwrap(); if let Err(e) = server.object_server().at("/", ObjectManager).await {
error!("Failed to register ObjectManager at root '/': {e:?}");
}
let config = Config::new().load(); let config = Config::new().load();
let cfg_path = config.file_path(); let cfg_path = config.file_path();
@@ -72,14 +74,17 @@ async fn start_daemon() -> Result<(), Box<dyn Error>> {
let platform = RogPlatform::new()?; // TODO: maybe needs async mutex? let platform = RogPlatform::new()?; // TODO: maybe needs async mutex?
let power = AsusPower::new()?; // TODO: maybe needs async mutex? let power = AsusPower::new()?; // TODO: maybe needs async mutex?
let attributes = FirmwareAttributes::new(); let attributes = FirmwareAttributes::new();
start_attributes_zbus( if let Err(e) = start_attributes_zbus(
&server, &server,
platform.clone(), platform.clone(),
power.clone(), power.clone(),
attributes.clone(), attributes.clone(),
config.clone(), config.clone(),
) )
.await?; .await
{
error!("Failed to initialize firmware attributes over zbus: {e:?}");
}
match CtrlFanCurveZbus::new() { match CtrlFanCurveZbus::new() {
Ok(ctrl) => { Ok(ctrl) => {