logged in and confirmed scopes worked
This commit is contained in:
parent
93a9524996
commit
d6741d5786
2 changed files with 13 additions and 9 deletions
|
|
@ -419,9 +419,8 @@ async fn start_component(
|
|||
//currently pid is optional hence the double unwrap
|
||||
let pids = process_manager.get_pid(key).await.unwrap().unwrap();
|
||||
//spawn_scope takes a vec of pids in case we want to spawn a scope for multiple processes
|
||||
spawn_scope(&format!("{cmd}.scope"), vec![pids])
|
||||
spawn_scope(cmd.to_string(), vec![pids])
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
process_manager.get_pid(key).await.unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,11 +48,17 @@ pub fn is_systemd_used() -> &'static bool {
|
|||
}
|
||||
|
||||
///Spawn a systemd scope unit with the given name and PIDs.
|
||||
pub async fn spawn_scope(scope_name: &str, pids: Vec<u32>) -> zbus::Result<()> {
|
||||
let connection = Connection::session().await?;
|
||||
let systemd_manager = SystemdManagerProxy::new(&connection).await?;
|
||||
let pids = OwnedValue::try_from(Value::Array(Array::from(pids)))?;
|
||||
pub async fn spawn_scope(mut scope_name: String, pids: Vec<u32>) {
|
||||
let connection = Connection::session().await.unwrap();
|
||||
let systemd_manager = SystemdManagerProxy::new(&connection).await.unwrap();
|
||||
let pids = OwnedValue::try_from(Array::from(pids)).unwrap();
|
||||
let properties = vec![(String::from("PIDs"), pids)];
|
||||
if scope_name.starts_with("/") {
|
||||
// use the last component of the path as the unit name
|
||||
scope_name = scope_name.rsplit('/').next().unwrap().to_string();
|
||||
}
|
||||
scope_name = format!("{}.scope", scope_name);
|
||||
info!("scope name is {}", scope_name);
|
||||
systemd_manager
|
||||
.start_transient_unit(
|
||||
scope_name.to_string(),
|
||||
|
|
@ -60,9 +66,8 @@ pub async fn spawn_scope(scope_name: &str, pids: Vec<u32>) -> zbus::Result<()> {
|
|||
properties,
|
||||
Vec::new(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// run a command, but log errors instead of returning them or panicking
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue