pull/9/head
prplV 2024-10-30 12:47:21 +03:00
parent e9bc8e5043
commit 572fbcd3eb
5 changed files with 20 additions and 60 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
/target /target
.idea .idea
Dockerfile Dockerfile
Cargo.lock Cargo.lock
settings.json

View File

@ -3,24 +3,16 @@
"configServer" : "localhost", "configServer" : "localhost",
"processes": [ "processes": [
{ {
"name": "web-server", "name": "temp-process",
"path": "/home/vladislav/web/web-server/run.sh", "path": "/home/user/monitor/runner-rs/temp-process",
"dependencies": { "dependencies": {
"files": [ "files": [
{ {
"filename": "control-file", "filename": "dep-file",
"src": "/home/vladislav/web/", "src": "/home/user/monitor/runner-rs/tests/examples/",
"triggers": { "triggers": {
"onDelete": "stop", "onDelete": "stop",
"onChange": "stop" "onChange": "stay"
}
},
{
"filename": "config-file",
"src": "/home/vladislav/web/",
"triggers": {
"onDelete": "stop",
"onChange": "restart"
} }
} }
], ],
@ -29,49 +21,13 @@
"hostname": "ya.ru", "hostname": "ya.ru",
"port": 443, "port": 443,
"triggers": { "triggers": {
"wait": 6, "wait": 10,
"delay": 1,
"onLost": "hold"
}
}
]
}
},
{
"name": "temp-process",
"path": "/home/vladislav/web/temp-process/run.sh",
"dependencies": {
"files": [
{
"filename": "control-file",
"src": "/home/vladislav/web/",
"triggers": {
"onDelete": "hold",
"onChange": "stop"
}
}
],
"services": [
{
"hostname": "google.com",
"port": 443,
"triggers": {
"wait": 5,
"delay": 1,
"onLost": "stop"
}
},
{
"hostname": "localhost",
"port": 8080,
"triggers": {
"wait": 6,
"delay": 2, "delay": 2,
"onLost": "stop" "onLost": "hold"
} }
} }
] ]
} }
} }
] ]
} }

View File

@ -182,8 +182,11 @@ fn invalid_config_watcher(conn: &mut Connection) -> Processes {
fn get_remote_config(conn: &mut Connection) -> Option<Processes> { fn get_remote_config(conn: &mut Connection) -> Option<Processes> {
let res: Res = conn.xrevrange_count("config_stream", "+", "-", 1); let res: Res = conn.xrevrange_count("config_stream", "+", "-", 1);
if res.is_ok() { if let Ok(result) = res {
let config = &res.unwrap()[0]; if result.is_empty() {
return None;
}
let config = &result[0];
if !config.is_empty() { if !config.is_empty() {
return parse_extern_config(&config[0].1[0].1); return parse_extern_config(&config[0].1[0].1);
} }

View File

@ -94,15 +94,15 @@ pub async fn restart_process(name: &str, path: &str) -> Result<(), CustomError>
} }
pub async fn start_process(name: &str, path: &str) -> Result<(), CustomError> { pub async fn start_process(name: &str, path: &str) -> Result<(), CustomError> {
// let runsh = format!("{}{}", path, "/run.sh"); // let runsh = format!("{} {}", "exec", path);
let mut command = Command::new("bash"); let mut command = Command::new(path);
command.arg(path); // command.arg(path);
match command.spawn() { match command.spawn() {
Ok(_) => { Ok(_) => {
warn!("Process {} is running now!", name); warn!("Process {} is running now!", name);
Ok(()) Ok(())
} }
Err(_) => Err(CustomError::Fatal), Err(er) => {println!("{:?}", er); Err(CustomError::Fatal)},
} }
} }

View File

@ -1 +1 @@
./$(pwd)/temp-process /home/user/monitor/runner-rs/temp-process