trying to figure out the ideal way to feature gate systemd
This commit is contained in:
parent
9409cae3f1
commit
b096107f81
2 changed files with 16 additions and 13 deletions
28
src/main.rs
28
src/main.rs
|
|
@ -415,18 +415,20 @@ async fn start_component(
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|_| panic!("failed to start {}", cmd));
|
.unwrap_or_else(|_| panic!("failed to start {}", cmd));
|
||||||
if *is_systemd_used() {
|
#[cfg(feature = "systemd")]
|
||||||
//currently pid is optional hence the double unwrap
|
{
|
||||||
let pids = process_manager.get_pid(key).await.unwrap().unwrap();
|
if *is_systemd_used() {
|
||||||
//spawn_scope takes a vec of pids in case we want to spawn a scope for multiple processes
|
//currently pid is optional hence the double unwrap
|
||||||
spawn_scope(cmd.to_string(), vec![pids])
|
let pids = process_manager.get_pid(key).await.unwrap().unwrap();
|
||||||
.await
|
//spawn_scope takes a vec of pids in case we want to spawn a scope for multiple processes
|
||||||
.unwrap_or_else(|err| {
|
spawn_scope(cmd.to_string(), vec![pids])
|
||||||
warn!(
|
.await
|
||||||
"Failed to spawn scope for {}. Creating transient unit failed with {}",
|
.unwrap_or_else(|err| {
|
||||||
cmd, err
|
warn!(
|
||||||
);
|
"Failed to spawn scope for {}. Creating transient unit failed with {}",
|
||||||
});
|
cmd, err
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
process_manager.get_pid(key).await.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ pub fn is_systemd_used() -> &'static bool {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "systemd")]
|
||||||
///Spawn a systemd scope unit with the given name and PIDs.
|
///Spawn a systemd scope unit with the given name and PIDs.
|
||||||
pub async fn spawn_scope(mut command: String, pids: Vec<u32>) -> Result<(), zbus::Error> {
|
pub async fn spawn_scope(mut command: String, pids: Vec<u32>) -> Result<(), zbus::Error> {
|
||||||
let connection = Connection::session().await?;
|
let connection = Connection::session().await?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue