Browse Source

Simplify

master
Adrian Heine 7 years ago
parent
commit
23fed5b6ca
  1. 33
      src/symbols/systemd/node_js_user_service.rs

33
src/symbols/systemd/node_js_user_service.rs

@ -126,31 +126,6 @@ impl<'a, C, R> NodeJsSystemdUserService<'a, C, R> where C: Deref<Target=str>, R:
} }
} }
fn wait_for_metadata(file_name: &str) -> Result<Metadata, Box<Error>> {
let result;
let mut tries = 5;
loop {
let metadata = fs::metadata(file_name.clone());
match metadata {
Ok(metadata) => {
result = metadata;
break;
},
Err(e) => {
if e.kind() != io::ErrorKind::NotFound {
return Err(Box::new(e));
}
}
}
tries -= 1;
if tries == 0 {
return Err("Gave up waiting for socket to appear".to_string().into());
}
sleep(Duration::from_millis(500));
}
Ok(result)
}
impl<'a, C, R> Symbol for NodeJsSystemdUserService<'a, C, R> where C: Deref<Target=str>, R: CommandRunner { impl<'a, C, R> Symbol for NodeJsSystemdUserService<'a, C, R> where C: Deref<Target=str>, R: CommandRunner {
fn target_reached(&self) -> Result<bool, Box<Error>> { fn target_reached(&self) -> Result<bool, Box<Error>> {
if !(try!(self.file.target_reached())) { if !(try!(self.file.target_reached())) {
@ -169,13 +144,7 @@ impl<'a, C, R> Symbol for NodeJsSystemdUserService<'a, C, R> where C: Deref<Targ
} }
let file_name = format!("/var/tmp/{}-{}.socket", self.user_name, self.service_name); let file_name = format!("/var/tmp/{}-{}.socket", self.user_name, self.service_name);
let metadata = try!(wait_for_metadata(&file_name));
/*
let mut perms = metadata.permissions();
perms.set_mode(0o666);
try!(fs::set_permissions(file_name, perms));
*/
Ok(())
fs::metadata(&file_name).map(|_| ()).map_err(|e| Box::new(e) as Box<Error>)
} }
fn get_prerequisites(&self) -> Vec<Resource> { fn get_prerequisites(&self) -> Vec<Resource> {

Loading…
Cancel
Save