make a good path for a service

This commit is contained in:
primardj 2024-04-07 22:01:39 +01:00
parent 7674e823b9
commit 36f77b3edb

View file

@ -1,11 +1,40 @@
use std::fs;
pub fn execute(svdir_var: String, svwait_var: i32, verbose: i8, command: &str, services: Vec<String>){ pub fn execute(svdir_var: String, svwait_var: i32, verbose: i8, command: &str, services: Vec<String>){
println!("execute in exec"); println!("execute in exec");
dbg!(svdir_var); dbg!(svdir_var.clone());
dbg!(svwait_var); dbg!(svwait_var);
dbg!(verbose); dbg!(verbose);
dbg!(command); dbg!(command);
dbg!(services);
for sv in services {
let ch1 = sv.chars().next().unwrap();
let ch2_row = &sv.chars().collect::<Vec<_>>()[..2];
let ch2: String = ch2_row.into_iter().collect();
let path;
if ch1 == '/' || ch2 == "~/"{
// case absolute path for the service
//
path = sv;
} else {
// case relative path for the service.
//
path = svdir_var.clone() + "/" + &sv;
}
dbg!(path);
// 1. Check if path exists.
//
// 2. Check if supervise/ok exist
//
// if not, error => increase by one the exit code and print a beatifull message in Err
// standard.
//
// if yes, sent the proper signal to supervise/control
//
// if verbose = 1, wait for the service to reach the proper state or timeout.
}
} }