Browse Source

Wait for socket in user service

master
Adrian Heine 5 years ago
parent
commit
de98c07251
  1. 20
      src/symbols/systemd/user_service.rs

20
src/symbols/systemd/user_service.rs

@ -2,7 +2,6 @@ use std::borrow::Cow;
use std::error::Error; use std::error::Error;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fmt; use std::fmt;
use std::fs;
use std::io; use std::io;
use std::path::Path; use std::path::Path;
@ -188,15 +187,18 @@ impl<'a, C: AsRef<str>, R: CommandRunner> Symbol for UserService<'a, C, R> {
self.systemctl_wait_for_dbus(args!["--user", "enable", self.service_name])?; self.systemctl_wait_for_dbus(args!["--user", "enable", self.service_name])?;
self.systemctl_wait_for_dbus(args!["--user", "restart", self.service_name])?; self.systemctl_wait_for_dbus(args!["--user", "restart", self.service_name])?;
if !(self.check_if_service()?) {
return Err(Box::new(
UserServiceError::GenericError as UserServiceError<io::Error>,
));
}
loop {
if !(self.check_if_service()?) {
return Err(Box::new(
UserServiceError::GenericError as UserServiceError<io::Error>,
));
}
fs::metadata(&self.socket_path)
.map(|_| ())
.map_err(|e| Box::new(e) as Box<dyn Error>)
if self.socket_path.exists() {
return Ok(());
}
sleep(Duration::from_millis(500));
}
} }
fn get_prerequisites(&self) -> Vec<Resource> { fn get_prerequisites(&self) -> Vec<Resource> {

Loading…
Cancel
Save