From f2a9af616833f1c9e2ca473642c0466029677d25 Mon Sep 17 00:00:00 2001 From: primardj Date: Sat, 13 Apr 2024 19:19:46 +0100 Subject: [PATCH 1/7] return to 2021 features, and add replace old way to detect error when trying to open fifo file --- 01_phase_rust_src/sv/Cargo.toml | 3 ++- 01_phase_rust_src/sv/src/status_obj/misc.rs | 22 ++++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/01_phase_rust_src/sv/Cargo.toml b/01_phase_rust_src/sv/Cargo.toml index 43f8a44..ba98c18 100644 --- a/01_phase_rust_src/sv/Cargo.toml +++ b/01_phase_rust_src/sv/Cargo.toml @@ -1,9 +1,10 @@ [package] name = "sv" version = "0.2.0" -edition = "2024" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] tokio = { version = "1.37.0", features = ["full"] } +libc = "0.2" diff --git a/01_phase_rust_src/sv/src/status_obj/misc.rs b/01_phase_rust_src/sv/src/status_obj/misc.rs index 85dbd6c..b01c341 100644 --- a/01_phase_rust_src/sv/src/status_obj/misc.rs +++ b/01_phase_rust_src/sv/src/status_obj/misc.rs @@ -1,6 +1,4 @@ -use std::io::ErrorKind; - use tokio::net::unix::pipe; use tokio::runtime::Runtime; @@ -85,18 +83,14 @@ pub fn check_fifo(sv: String, path: &str) -> bool { let sender = pipe::OpenOptions::new().open_sender(path); match sender { - Ok(..) => {}, - Err(e) => match e.kind() { - ErrorKind::NotFound => { - println!("warning: {sv}: unable to open {path}: file does not exist"); - return false; - }, - _ => { - println!("fail: {sv}: runsv not running"); - return false; - } + Ok(..) => return true, + Err(e) if e.raw_os_error() == Some(libc::ENXIO) => { + println!("fail: {sv}: runsv not running"); + return false; + }, + Err(..) => { + println!("warning: {sv}: unable to open {path}: file does not exist"); + return false; }, }; - - return true } From c0ae3d3aed51f956f229502dcf917a1fff1fd79d Mon Sep 17 00:00:00 2001 From: primardj Date: Sat, 13 Apr 2024 19:52:51 +0100 Subject: [PATCH 2/7] implem sent_signal and command u --- .../sv/src/executor/sent_signal.rs | 11 ++++++ 01_phase_rust_src/sv/src/status_obj.rs | 5 +++ 01_phase_rust_src/sv/src/status_obj/misc.rs | 38 +++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/01_phase_rust_src/sv/src/executor/sent_signal.rs b/01_phase_rust_src/sv/src/executor/sent_signal.rs index bee4cb3..67b891e 100644 --- a/01_phase_rust_src/sv/src/executor/sent_signal.rs +++ b/01_phase_rust_src/sv/src/executor/sent_signal.rs @@ -27,6 +27,17 @@ pub fn sent_signal( svwait_var: i32, verbose: i8, command: &str, mut sv: status_ return 0; } + if command == "u" { + // case where command is up + if sv.sent_signal(b"u") == true { + println!("Tout c bien passé"); + return 0; + } else { + println!("Ko Error panic tout ce que tu veux."); + return 1; + } + } + //let service = fs::OpenOptions::new().append(true).open("supervise/control"); //if ! service.is_ok() { diff --git a/01_phase_rust_src/sv/src/status_obj.rs b/01_phase_rust_src/sv/src/status_obj.rs index 8ca8c69..225319f 100644 --- a/01_phase_rust_src/sv/src/status_obj.rs +++ b/01_phase_rust_src/sv/src/status_obj.rs @@ -173,6 +173,10 @@ impl StatusObj { return return_string; } + pub fn sent_signal(&mut self, signal: &[u8]) -> bool { + return misc::sent_signal(signal); + } + pub fn get_log(&mut self) -> bool { return self.log; } @@ -180,5 +184,6 @@ impl StatusObj { pub fn get_obj_log(&mut self) -> Option { return StatusObj::new(self.svpath.clone() + "/log", "log".to_string()); } + } diff --git a/01_phase_rust_src/sv/src/status_obj/misc.rs b/01_phase_rust_src/sv/src/status_obj/misc.rs index b01c341..c6ad018 100644 --- a/01_phase_rust_src/sv/src/status_obj/misc.rs +++ b/01_phase_rust_src/sv/src/status_obj/misc.rs @@ -1,6 +1,7 @@ use tokio::net::unix::pipe; use tokio::runtime::Runtime; +use std::io::ErrorKind; pub fn make_pause_run(pr_int: u8) -> bool { if pr_int == 0 { @@ -94,3 +95,40 @@ pub fn check_fifo(sv: String, path: &str) -> bool { }, }; } + +pub fn sent_signal(signal: &[u8]) -> bool { + // sent the char to supervise/control. + // return true in case everything worked fine, false if there was any errors. + let rt = Runtime::new().unwrap(); + let _guard = rt.enter(); + + let sender = pipe::OpenOptions::new().open_sender("supervise/control"); + match sender { + Ok(tx) => { + loop { + match tx.try_write(signal) { + Ok(..) => { + println!("write successful"); + return true; + }, + Err(e) if e.kind() == ErrorKind::WouldBlock => { + continue; + }, + Err(e) => { + dbg!(e); + println!("Error while trying to sent command"); + return false; + }, + } + }; + }, + Err(e) if e.raw_os_error() == Some(libc::ENXIO) => { + println!("fail: sv: runsv not running"); + return false; + }, + Err(..) => { + println!("warning: sv: unable to open path: file does not exist"); + return false; + }, + }; +} From 707d7a2f3dba06fa65484ee326a31b10af8ed5dd Mon Sep 17 00:00:00 2001 From: primardj Date: Sat, 13 Apr 2024 19:57:16 +0100 Subject: [PATCH 3/7] rename sv to sv-rustit --- 01_phase_rust_src/{sv => sv-rustit}/Cargo.toml | 2 +- 01_phase_rust_src/{sv => sv-rustit}/src/executor.rs | 0 01_phase_rust_src/{sv => sv-rustit}/src/executor/sent_signal.rs | 0 01_phase_rust_src/{sv => sv-rustit}/src/main.rs | 0 01_phase_rust_src/{sv => sv-rustit}/src/parser.rs | 0 01_phase_rust_src/{sv => sv-rustit}/src/parser/misc.rs | 0 01_phase_rust_src/{sv => sv-rustit}/src/status_obj.rs | 0 01_phase_rust_src/{sv => sv-rustit}/src/status_obj/misc.rs | 0 8 files changed, 1 insertion(+), 1 deletion(-) rename 01_phase_rust_src/{sv => sv-rustit}/Cargo.toml (92%) rename 01_phase_rust_src/{sv => sv-rustit}/src/executor.rs (100%) rename 01_phase_rust_src/{sv => sv-rustit}/src/executor/sent_signal.rs (100%) rename 01_phase_rust_src/{sv => sv-rustit}/src/main.rs (100%) rename 01_phase_rust_src/{sv => sv-rustit}/src/parser.rs (100%) rename 01_phase_rust_src/{sv => sv-rustit}/src/parser/misc.rs (100%) rename 01_phase_rust_src/{sv => sv-rustit}/src/status_obj.rs (100%) rename 01_phase_rust_src/{sv => sv-rustit}/src/status_obj/misc.rs (100%) diff --git a/01_phase_rust_src/sv/Cargo.toml b/01_phase_rust_src/sv-rustit/Cargo.toml similarity index 92% rename from 01_phase_rust_src/sv/Cargo.toml rename to 01_phase_rust_src/sv-rustit/Cargo.toml index ba98c18..77d1906 100644 --- a/01_phase_rust_src/sv/Cargo.toml +++ b/01_phase_rust_src/sv-rustit/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sv" +name = "sv-rustit" version = "0.2.0" edition = "2021" diff --git a/01_phase_rust_src/sv/src/executor.rs b/01_phase_rust_src/sv-rustit/src/executor.rs similarity index 100% rename from 01_phase_rust_src/sv/src/executor.rs rename to 01_phase_rust_src/sv-rustit/src/executor.rs diff --git a/01_phase_rust_src/sv/src/executor/sent_signal.rs b/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs similarity index 100% rename from 01_phase_rust_src/sv/src/executor/sent_signal.rs rename to 01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs diff --git a/01_phase_rust_src/sv/src/main.rs b/01_phase_rust_src/sv-rustit/src/main.rs similarity index 100% rename from 01_phase_rust_src/sv/src/main.rs rename to 01_phase_rust_src/sv-rustit/src/main.rs diff --git a/01_phase_rust_src/sv/src/parser.rs b/01_phase_rust_src/sv-rustit/src/parser.rs similarity index 100% rename from 01_phase_rust_src/sv/src/parser.rs rename to 01_phase_rust_src/sv-rustit/src/parser.rs diff --git a/01_phase_rust_src/sv/src/parser/misc.rs b/01_phase_rust_src/sv-rustit/src/parser/misc.rs similarity index 100% rename from 01_phase_rust_src/sv/src/parser/misc.rs rename to 01_phase_rust_src/sv-rustit/src/parser/misc.rs diff --git a/01_phase_rust_src/sv/src/status_obj.rs b/01_phase_rust_src/sv-rustit/src/status_obj.rs similarity index 100% rename from 01_phase_rust_src/sv/src/status_obj.rs rename to 01_phase_rust_src/sv-rustit/src/status_obj.rs diff --git a/01_phase_rust_src/sv/src/status_obj/misc.rs b/01_phase_rust_src/sv-rustit/src/status_obj/misc.rs similarity index 100% rename from 01_phase_rust_src/sv/src/status_obj/misc.rs rename to 01_phase_rust_src/sv-rustit/src/status_obj/misc.rs From 1bcbcc908249fffd59050e07cffc0af960d8d903 Mon Sep 17 00:00:00 2001 From: primardj Date: Sat, 13 Apr 2024 20:00:41 +0100 Subject: [PATCH 4/7] rename svlogd svlogd-rustit and chpst chpst-rustit --- 01_phase_rust_src/{chpst => chpst-rustit}/Cargo.toml | 2 +- 01_phase_rust_src/{chpst => chpst-rustit}/src/main.rs | 0 01_phase_rust_src/{svlogd => svlogd-rustit}/Cargo.toml | 2 +- 01_phase_rust_src/{svlogd => svlogd-rustit}/src/main.rs | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename 01_phase_rust_src/{chpst => chpst-rustit}/Cargo.toml (87%) rename 01_phase_rust_src/{chpst => chpst-rustit}/src/main.rs (100%) rename 01_phase_rust_src/{svlogd => svlogd-rustit}/Cargo.toml (87%) rename 01_phase_rust_src/{svlogd => svlogd-rustit}/src/main.rs (100%) diff --git a/01_phase_rust_src/chpst/Cargo.toml b/01_phase_rust_src/chpst-rustit/Cargo.toml similarity index 87% rename from 01_phase_rust_src/chpst/Cargo.toml rename to 01_phase_rust_src/chpst-rustit/Cargo.toml index 5e25448..b02b937 100644 --- a/01_phase_rust_src/chpst/Cargo.toml +++ b/01_phase_rust_src/chpst-rustit/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "chpst" +name = "chpst-rustit" version = "0.1.0" edition = "2021" diff --git a/01_phase_rust_src/chpst/src/main.rs b/01_phase_rust_src/chpst-rustit/src/main.rs similarity index 100% rename from 01_phase_rust_src/chpst/src/main.rs rename to 01_phase_rust_src/chpst-rustit/src/main.rs diff --git a/01_phase_rust_src/svlogd/Cargo.toml b/01_phase_rust_src/svlogd-rustit/Cargo.toml similarity index 87% rename from 01_phase_rust_src/svlogd/Cargo.toml rename to 01_phase_rust_src/svlogd-rustit/Cargo.toml index 97e19c5..3d778a6 100644 --- a/01_phase_rust_src/svlogd/Cargo.toml +++ b/01_phase_rust_src/svlogd-rustit/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "svlogd" +name = "svlogd-rustit" version = "0.1.0" edition = "2021" diff --git a/01_phase_rust_src/svlogd/src/main.rs b/01_phase_rust_src/svlogd-rustit/src/main.rs similarity index 100% rename from 01_phase_rust_src/svlogd/src/main.rs rename to 01_phase_rust_src/svlogd-rustit/src/main.rs From 6d9fb61ef85e0fbd59fb29f268a1e8a1afcdf1d6 Mon Sep 17 00:00:00 2001 From: primardj Date: Sat, 13 Apr 2024 20:19:00 +0100 Subject: [PATCH 5/7] correct printing in code, suppress useless comments. --- .../sv-rustit/src/executor/sent_signal.rs | 14 +------------- 01_phase_rust_src/sv-rustit/src/status_obj/misc.rs | 5 ++--- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs b/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs index 67b891e..f3e4316 100644 --- a/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs +++ b/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs @@ -29,25 +29,13 @@ pub fn sent_signal( svwait_var: i32, verbose: i8, command: &str, mut sv: status_ if command == "u" { // case where command is up - if sv.sent_signal(b"u") == true { - println!("Tout c bien passé"); + if sv.sent_signal(b"u") { return 0; } else { - println!("Ko Error panic tout ce que tu veux."); return 1; } } - //let service = fs::OpenOptions::new().append(true).open("supervise/control"); - - //if ! service.is_ok() { - // println!("warning: {}: unable to append to supervise/control: file does not exist", sv.clone()); - // return make_exit_code(exit_code); - //} - //let mut control = match service { - // Ok(file) => file, - // Err(..) => panic!("Shouln't goes there, the programmer is trash."), - //}; // TODO diff --git a/01_phase_rust_src/sv-rustit/src/status_obj/misc.rs b/01_phase_rust_src/sv-rustit/src/status_obj/misc.rs index c6ad018..731d92f 100644 --- a/01_phase_rust_src/sv-rustit/src/status_obj/misc.rs +++ b/01_phase_rust_src/sv-rustit/src/status_obj/misc.rs @@ -108,7 +108,6 @@ pub fn sent_signal(signal: &[u8]) -> bool { loop { match tx.try_write(signal) { Ok(..) => { - println!("write successful"); return true; }, Err(e) if e.kind() == ErrorKind::WouldBlock => { @@ -116,10 +115,10 @@ pub fn sent_signal(signal: &[u8]) -> bool { }, Err(e) => { dbg!(e); - println!("Error while trying to sent command"); + println!("Impossible Error while writing on pipe."); return false; }, - } + }; }; }, Err(e) if e.raw_os_error() == Some(libc::ENXIO) => { From 94f8aebd3a7b57afc1d9335f94c3c96e6afdd074 Mon Sep 17 00:00:00 2001 From: primardj Date: Sat, 13 Apr 2024 23:24:59 +0100 Subject: [PATCH 6/7] add verbose, svwait and down command --- .../sv-rustit/src/executor/sent_signal.rs | 75 +++++++++++++++---- .../src/executor/sent_signal/misc.rs | 21 ++++++ 01_phase_rust_src/sv-rustit/src/status_obj.rs | 13 ++++ 3 files changed, 94 insertions(+), 15 deletions(-) create mode 100644 01_phase_rust_src/sv-rustit/src/executor/sent_signal/misc.rs diff --git a/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs b/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs index f3e4316..07e90a8 100644 --- a/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs +++ b/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs @@ -1,41 +1,86 @@ +mod misc; use crate::status_obj; +use std::thread::sleep; +use std::time::Duration; + pub fn sent_signal( svwait_var: i32, verbose: i8, command: &str, mut sv: status_obj::StatusObj) -> i32 { // Return 0 in case everything worked fine, return 1 if timeout or error. dbg!(svwait_var); dbg!(verbose); + + let mut time_wait = 0; // execute command. if command == "s" { // case command is status - let mut status_sv = sv.get_status_string(); - let is_log = sv.get_log(); - if is_log { - let log_option = sv.get_obj_log(); - match log_option { - Some(mut log) => { - status_sv = status_sv + "; " + &log.get_status_string(); - }, - None => {// TODO: Do nothing for now, eventually, increase by one exit code. - }, - }; - } - println!("{}", status_sv); - return 0; + return misc::print_status(sv); } if command == "u" { // case where command is up if sv.sent_signal(b"u") { - return 0; + if verbose == 1 { + loop { + // TODO, Make a method update_sv + let sv_option = status_obj::StatusObj::new(sv.get_path(), sv.get_name()); + let mut sv_new = match sv_option { + Some(service) => service, + None => return 1, + }; + if sv_new.is_up() == true { + misc::print_status(sv_new); + return 0 + } + if time_wait >= svwait_var { + println!("fail: {}: timeout", sv_new.get_name()); + return 1 + } + + time_wait += 1; + sleep(Duration::from_secs(1)); + } + } else { + return 0; + } } else { return 1; } } + if command == "d" { + // case where command is up + if sv.sent_signal(b"d") { + if verbose == 1 { + loop { + // TODO: Use the update_service method instead of creating another sv. + let sv_option = status_obj::StatusObj::new(sv.get_path(), sv.get_name()); + let mut sv_new = match sv_option { + Some(service) => service, + None => return 1, + }; + if sv_new.is_up() == false { + misc::print_status(sv_new); + return 0 + } + if time_wait >= svwait_var { + println!("fail: {}: timeout", sv_new.get_name()); + return 1 + } + + time_wait += 1; + sleep(Duration::from_secs(1)); + } + } else { + return 0; + } + } else { + return 1; + } + } // TODO diff --git a/01_phase_rust_src/sv-rustit/src/executor/sent_signal/misc.rs b/01_phase_rust_src/sv-rustit/src/executor/sent_signal/misc.rs new file mode 100644 index 0000000..7a8e2a5 --- /dev/null +++ b/01_phase_rust_src/sv-rustit/src/executor/sent_signal/misc.rs @@ -0,0 +1,21 @@ + +use crate::status_obj; + +pub fn print_status(mut sv: status_obj::StatusObj) -> i32 { + // The status code is the one who will be + let mut status_sv = sv.get_status_string(); + let is_log = sv.get_log(); + if is_log { + let log_option = sv.get_obj_log(); + match log_option { + Some(mut log) => { + status_sv = status_sv + "; " + &log.get_status_string(); + }, + None => { + return 1 + }, + }; + } + println!("{}", status_sv); + return 0; +} diff --git a/01_phase_rust_src/sv-rustit/src/status_obj.rs b/01_phase_rust_src/sv-rustit/src/status_obj.rs index 225319f..fb7b0f8 100644 --- a/01_phase_rust_src/sv-rustit/src/status_obj.rs +++ b/01_phase_rust_src/sv-rustit/src/status_obj.rs @@ -8,6 +8,7 @@ use std::io::prelude::*; use std::time::SystemTime; +#[derive(Debug)] pub struct StatusObj { svname: String, // Service name svpath: String, // Service path @@ -177,6 +178,18 @@ impl StatusObj { return misc::sent_signal(signal); } + pub fn is_up(&mut self) -> bool { + return self.run_finish; + } + + pub fn get_name(&mut self) -> String { + return self.svname.clone(); + } + + pub fn get_path(&mut self) -> String { + return self.svpath.clone(); + } + pub fn get_log(&mut self) -> bool { return self.log; } From cb8768b6f5ec3af91f49170d7a7dd0e631490074 Mon Sep 17 00:00:00 2001 From: primardj Date: Sat, 13 Apr 2024 23:41:11 +0100 Subject: [PATCH 7/7] add method status_update and do optimisation on up and down verbose command. --- .../sv-rustit/src/executor/sent_signal.rs | 35 +++++-------- 01_phase_rust_src/sv-rustit/src/status_obj.rs | 51 +++++++++++++++++++ 2 files changed, 65 insertions(+), 21 deletions(-) diff --git a/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs b/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs index 07e90a8..9955f42 100644 --- a/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs +++ b/01_phase_rust_src/sv-rustit/src/executor/sent_signal.rs @@ -9,9 +9,6 @@ use std::time::Duration; pub fn sent_signal( svwait_var: i32, verbose: i8, command: &str, mut sv: status_obj::StatusObj) -> i32 { // Return 0 in case everything worked fine, return 1 if timeout or error. - dbg!(svwait_var); - dbg!(verbose); - let mut time_wait = 0; // execute command. @@ -25,18 +22,16 @@ pub fn sent_signal( svwait_var: i32, verbose: i8, command: &str, mut sv: status_ if sv.sent_signal(b"u") { if verbose == 1 { loop { - // TODO, Make a method update_sv - let sv_option = status_obj::StatusObj::new(sv.get_path(), sv.get_name()); - let mut sv_new = match sv_option { - Some(service) => service, - None => return 1, - }; - if sv_new.is_up() == true { - misc::print_status(sv_new); + let status = sv.update_status(); + if status == 1 { + return 1; + } + if sv.is_up() == true { + misc::print_status(sv); return 0 } if time_wait >= svwait_var { - println!("fail: {}: timeout", sv_new.get_name()); + println!("fail: {}: timeout", sv.get_name()); return 1 } @@ -56,18 +51,16 @@ pub fn sent_signal( svwait_var: i32, verbose: i8, command: &str, mut sv: status_ if sv.sent_signal(b"d") { if verbose == 1 { loop { - // TODO: Use the update_service method instead of creating another sv. - let sv_option = status_obj::StatusObj::new(sv.get_path(), sv.get_name()); - let mut sv_new = match sv_option { - Some(service) => service, - None => return 1, - }; - if sv_new.is_up() == false { - misc::print_status(sv_new); + let status = sv.update_status(); + if status == 1 { + return 1; + } + if sv.is_up() == false { + misc::print_status(sv); return 0 } if time_wait >= svwait_var { - println!("fail: {}: timeout", sv_new.get_name()); + println!("fail: {}: timeout", sv.get_name()); return 1 } diff --git a/01_phase_rust_src/sv-rustit/src/status_obj.rs b/01_phase_rust_src/sv-rustit/src/status_obj.rs index fb7b0f8..10a26b3 100644 --- a/01_phase_rust_src/sv-rustit/src/status_obj.rs +++ b/01_phase_rust_src/sv-rustit/src/status_obj.rs @@ -113,6 +113,57 @@ impl StatusObj { }) } + pub fn update_status(&mut self) -> u32 { + // Update only status related fields. + // return 1 in case there is a problem. + // return 0 if everything is altight. + let status_option = fs::OpenOptions::new().read(true).open("supervise/status"); + let mut status = match status_option { + Ok(file) => file, + Err(..) => { + println!("warning: {}: unable to open supervise/status: file does not exist", self.svname); + return 1; + }, + }; + let mut contents: Vec = Vec::new(); + let option_size = status.read_to_end(&mut contents); + + let size = match option_size { + Ok(size) => size, + Err(..) => { + println!("warning: {}: couldn't read supervise/status", self.svname); + return 1 + }, + }; + + if size != 20 { + println!("warning: {}: bad supervise/status format", self.svname); + return 1 + } + + let time_buf: Vec = contents[0..8].to_vec(); + //let nano_buf: Vec = contents[8..12].to_vec(); + let pid_buf: Vec = contents[12..16].to_vec(); + + let seconds = misc::return_u8_in_u64(time_buf); + //let nano = misc::return_u8_in_u32(nano_buf); + let pid_found = misc::return_reverse_u8_in_u32(pid_buf); + + let pause_run_raw = misc::make_pause_run(contents[16]); // done + let up_down_raw = misc::make_up_down(contents[17]); // done + let term_sig_raw = misc::make_term_sig(contents[18]); // done + let run_finish_raw = misc::make_run_finish(contents[19]); // done + + self.time = seconds; + self.pid = pid_found; + self.pause_run = pause_run_raw; + self.up_down = up_down_raw; + self.term_sig = term_sig_raw; + self.run_finish = run_finish_raw; + + return 0; + } + pub fn get_status_string(&mut self) -> String { // return the status for this service in particular.