trying to figure out the ideal way to feature gate systemd

This commit is contained in:
Joshua Ferguson 2024-06-21 18:03:30 -04:00 committed by Ashley Wulber
parent 9409cae3f1
commit b096107f81
2 changed files with 16 additions and 13 deletions

View file

@ -415,6 +415,8 @@ async fn start_component(
) )
.await .await
.unwrap_or_else(|_| panic!("failed to start {}", cmd)); .unwrap_or_else(|_| panic!("failed to start {}", cmd));
#[cfg(feature = "systemd")]
{
if *is_systemd_used() { if *is_systemd_used() {
//currently pid is optional hence the double unwrap //currently pid is optional hence the double unwrap
let pids = process_manager.get_pid(key).await.unwrap().unwrap(); let pids = process_manager.get_pid(key).await.unwrap().unwrap();
@ -428,5 +430,5 @@ async fn start_component(
); );
}); });
} }
process_manager.get_pid(key).await.unwrap(); }
} }

View file

@ -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?;