try change to service directory
This commit is contained in:
parent
36f77b3edb
commit
61ccac3415
1 changed files with 23 additions and 4 deletions
|
@ -1,14 +1,19 @@
|
|||
|
||||
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::env::set_current_dir;
|
||||
|
||||
pub fn execute(svdir_var: String, svwait_var: i32, verbose: i8, command: &str, services: Vec<String>){
|
||||
// TODO: Return the exec code.
|
||||
println!("execute in exec");
|
||||
dbg!(svdir_var.clone());
|
||||
dbg!(svwait_var);
|
||||
dbg!(verbose);
|
||||
dbg!(command);
|
||||
|
||||
let mut exit_code: i32 = 0;
|
||||
|
||||
for sv in services {
|
||||
let ch1 = sv.chars().next().unwrap();
|
||||
let ch2_row = &sv.chars().collect::<Vec<_>>()[..2];
|
||||
|
@ -18,15 +23,29 @@ pub fn execute(svdir_var: String, svwait_var: i32, verbose: i8, command: &str, s
|
|||
if ch1 == '/' || ch2 == "~/"{
|
||||
// case absolute path for the service
|
||||
//
|
||||
path = sv;
|
||||
path = sv.clone();
|
||||
} else {
|
||||
// case relative path for the service.
|
||||
//
|
||||
path = svdir_var.clone() + "/" + &sv;
|
||||
}
|
||||
dbg!(path);
|
||||
// 1. Check if path exists.
|
||||
//
|
||||
|
||||
// 1. Check if path exists.
|
||||
//
|
||||
let path_to_sv = Path::new(&path);
|
||||
|
||||
if set_current_dir(path_to_sv).is_ok() {
|
||||
println!("Set path okay.");
|
||||
// TODO: make a function which do what's next.
|
||||
// It will be called, sent_signal, will return 0 if no error, and 1 if an error.
|
||||
} else {
|
||||
println!("fail: {}: unable to change to service directory: file does not exist", sv);
|
||||
if exit_code < 99 {
|
||||
exit_code += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
// 2. Check if supervise/ok exist
|
||||
//
|
||||
// if not, error => increase by one the exit code and print a beatifull message in Err
|
||||
|
|
Loading…
Reference in a new issue