feat: try to gracefully shut down settings daemon when exiting
This commit is contained in:
parent
2612282fcf
commit
60ff2241ed
3 changed files with 36 additions and 16 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
|
@ -694,10 +694,10 @@ checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "launch-pad"
|
name = "launch-pad"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/launch-pad#a267ea1fe5f80b30f82b8ec557a88b23fa4ebdc3"
|
source = "git+https://github.com/pop-os/launch-pad?branch=feat-graceful-stop#e1f20362928555b33e4e38eb8f41af734c5c03b4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"nix 0.26.2",
|
"nix 0.26.4",
|
||||||
"rand",
|
"rand",
|
||||||
"slotmap",
|
"slotmap",
|
||||||
"sync_wrapper",
|
"sync_wrapper",
|
||||||
|
|
@ -833,16 +833,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.26.2"
|
version = "0.26.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a"
|
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"memoffset 0.7.1",
|
"memoffset 0.7.1",
|
||||||
"pin-utils",
|
"pin-utils",
|
||||||
"static_assertions",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
@ -1225,9 +1224,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slotmap"
|
name = "slotmap"
|
||||||
version = "1.0.6"
|
version = "1.0.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342"
|
checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
@ -1267,9 +1266,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sync_wrapper"
|
name = "sync_wrapper"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
|
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
|
|
@ -1287,18 +1286,18 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.41"
|
version = "1.0.65"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c16a64ba9387ef3fdae4f9c1a7f07a0997fce91985c0336f1ddc1822b3b37802"
|
checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.41"
|
version = "1.0.65"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d14928354b01c4d6a4f0e549069adef399a284e7995c7ccca94e8a07a5346c59"
|
checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ color-eyre = "0.6"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
cosmic-dbus-a11y = { git = "https://github.com/pop-os/dbus-settings-bindings" }
|
cosmic-dbus-a11y = { git = "https://github.com/pop-os/dbus-settings-bindings" }
|
||||||
|
|
||||||
launch-pad = { git = "https://github.com/pop-os/launch-pad" }
|
# launch-pad = { git = "https://github.com/pop-os/launch-pad" }
|
||||||
itertools = "0.12"
|
itertools = "0.12"
|
||||||
#launch-pad = { git = "https://github.com/pop-os/launch-pad", branch = "remove-sync-bounds" }
|
launch-pad = { git = "https://github.com/pop-os/launch-pad", branch = "feat-graceful-stop" }
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
log-panics = { version = "2", features = ["with-backtrace"] }
|
log-panics = { version = "2", features = ["with-backtrace"] }
|
||||||
rustix = "0.38"
|
rustix = "0.38"
|
||||||
|
|
|
||||||
23
src/main.rs
23
src/main.rs
|
|
@ -162,7 +162,9 @@ async fn start(
|
||||||
|
|
||||||
let stdout_span = info_span!(parent: None, "cosmic-settings-daemon");
|
let stdout_span = info_span!(parent: None, "cosmic-settings-daemon");
|
||||||
let stderr_span = stdout_span.clone();
|
let stderr_span = stdout_span.clone();
|
||||||
process_manager
|
let (settings_exit_tx, settings_exit_rx) = oneshot::channel();
|
||||||
|
let settings_exit_tx = Arc::new(std::sync::Mutex::new(Some(settings_exit_tx)));
|
||||||
|
let settings_daemon = process_manager
|
||||||
.start(
|
.start(
|
||||||
Process::new()
|
Process::new()
|
||||||
.with_executable("cosmic-settings-daemon")
|
.with_executable("cosmic-settings-daemon")
|
||||||
|
|
@ -179,6 +181,14 @@ async fn start(
|
||||||
warn!("{}", line);
|
warn!("{}", line);
|
||||||
}
|
}
|
||||||
.instrument(stderr_span)
|
.instrument(stderr_span)
|
||||||
|
})
|
||||||
|
.with_on_exit(move |_, _, _, will_restart| {
|
||||||
|
if !will_restart {
|
||||||
|
if let Some(tx) = settings_exit_tx.lock().unwrap().take() {
|
||||||
|
_ = tx.send(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async {}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
@ -403,6 +413,17 @@ async fn start(
|
||||||
}
|
}
|
||||||
compositor_handle.abort();
|
compositor_handle.abort();
|
||||||
token.cancel();
|
token.cancel();
|
||||||
|
if let Err(err) = process_manager.stop_process(settings_daemon).await {
|
||||||
|
tracing::error!("Failed to gracefully stop settings daemon. {err:?}");
|
||||||
|
} else {
|
||||||
|
match tokio::time::timeout(Duration::from_secs(1), settings_exit_rx).await {
|
||||||
|
Ok(Ok(_)) => {}
|
||||||
|
_ => {
|
||||||
|
tracing::error!("Failed to gracefully stop settings daemon.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
|
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
|
||||||
Ok(status)
|
Ok(status)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue