Skip to content

Commit

Permalink
chore: print error info about failed daemon connection
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-zlobintsev committed Nov 25, 2023
1 parent 2009007 commit 030e827
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 27 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lact-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lact-cli"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion lact-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lact-client"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion lact-daemon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lact-daemon"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

[features]
Expand Down
2 changes: 1 addition & 1 deletion lact-gui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lact-gui"
version = "0.5.0"
version = "0.5.1"
authors = ["Ilya Zlobintsev <[email protected]>"]
edition = "2021"

Expand Down
16 changes: 10 additions & 6 deletions lact-gui/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl App {
}
}

pub fn run(self) -> anyhow::Result<()> {
pub fn run(self, connection_err: Option<anyhow::Error>) -> anyhow::Result<()> {
self.application
.connect_activate(clone!(@strong self as app => move |_| {
app.window.set_application(Some(&app.application));
Expand Down Expand Up @@ -151,13 +151,17 @@ impl App {
app.window.show();

if app.daemon_client.embedded {
let text = "Could not connect to daemon, running in embedded mode. \n\
let error_text = connection_err.as_ref().map(|err| {
format!("Error info: {err:#}\n\n")
}).unwrap_or_default();

let text = format!("Could not connect to daemon, running in embedded mode. \n\
Please make sure the lactd service is running. \n\
Using embedded mode, you will not be able to change any settings. \n\
\n\
To enable the daemon, run the following command:";
Using embedded mode, you will not be able to change any settings. \n\n\
{error_text}\
To enable the daemon, run the following command:");

let text_label = Label::new(Some(text));
let text_label = Label::new(Some(&text));
let enable_label = Entry::builder()
.text("sudo systemctl enable --now lactd")
.editable(false)
Expand Down
13 changes: 7 additions & 6 deletions lact-gui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ pub fn run(args: GuiArgs) -> anyhow::Result<()> {
return Err(anyhow!("Cannot initialize GTK: {err}"));
}

let connection = create_connection()?;
let (connection, connection_err) = create_connection()?;
let app = App::new(connection);

app.run()
app.run(connection_err)
}

fn create_connection() -> anyhow::Result<DaemonClient> {
fn create_connection() -> anyhow::Result<(DaemonClient, Option<anyhow::Error>)> {
match DaemonClient::connect() {
Ok(connection) => Ok(connection),
Ok(connection) => Ok((connection, None)),
Err(err) => {
info!("could not connect to socket: {err}");
info!("could not connect to socket: {err:#}");
info!("using a local daemon");

let (server_stream, client_stream) = UnixStream::pair()?;
Expand All @@ -42,7 +42,8 @@ fn create_connection() -> anyhow::Result<DaemonClient> {
}
});

DaemonClient::from_stream(client_stream, true)
let client = DaemonClient::from_stream(client_stream, true)?;
Ok((client, Some(err)))
}
}
}
2 changes: 1 addition & 1 deletion lact-schema/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lact-schema"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

[features]
Expand Down
2 changes: 1 addition & 1 deletion lact/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lact"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

[features]
Expand Down
2 changes: 1 addition & 1 deletion pkg/recipes/lact/recipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ metadata:
description: AMDGPU control utility
arch: x86_64
license: MIT
version: 0.5.0
version: 0.5.1
maintainer: ilya-zlobintsev
url: https://github.com/ilya-zlobintsev/lact
source:
Expand Down

0 comments on commit 030e827

Please sign in to comment.