error: TypeError: Bulk response (response was [bulk(string-data('"1721382102455-0"'), bulk(string-data('"config"'), string-data('"{ ...
parent
9cbf17647d
commit
2a121589f7
29
src/main.rs
29
src/main.rs
|
|
@ -1,4 +1,4 @@
|
||||||
use redis::Commands;
|
use redis::{Commands, ConnectionAddr};
|
||||||
// json parsing
|
// json parsing
|
||||||
use serde::{ Deserialize, Serialize };
|
use serde::{ Deserialize, Serialize };
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
@ -19,9 +19,9 @@ use std::sync::Arc;
|
||||||
use inotify::{ Inotify, WatchMask };
|
use inotify::{ Inotify, WatchMask };
|
||||||
// logging
|
// logging
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use chrono::Local;
|
use chrono::{ Local, NaiveDate };
|
||||||
use env_logger::Builder;
|
use env_logger::Builder;
|
||||||
use log::{error, log, max_level, warn, LevelFilter};
|
use log::{error, warn, LevelFilter};
|
||||||
|
|
||||||
/// # an Error enum (nextly will be deleted and replaced)
|
/// # an Error enum (nextly will be deleted and replaced)
|
||||||
enum CustomError {
|
enum CustomError {
|
||||||
|
|
@ -142,11 +142,22 @@ async fn main() {
|
||||||
error!("Cannot find needed stream to get configuration");
|
error!("Cannot find needed stream to get configuration");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let config: String = conn.xrevrange("config_stream", "", "").inspect_err(|_| {
|
// error
|
||||||
error!("Cannot fetch config");
|
let config: Vec<(String, Vec<(String, String)>)> = conn.xrevrange_count("config_stream", "+", "-", 1)
|
||||||
return String::new();
|
.unwrap_or_else(|er| {
|
||||||
|
println!("error: {}", er);
|
||||||
|
return Vec::new();
|
||||||
});
|
});
|
||||||
let processes = parse_extern_config(&config);
|
println!("external config: {:?}", config);
|
||||||
|
|
||||||
|
let processes: Processes;
|
||||||
|
if config.is_empty() {
|
||||||
|
error!("No suitable config was given. Getting local config...");
|
||||||
|
processes = load_processes("settings.json");
|
||||||
|
} else {
|
||||||
|
println!("{:?}+++{}", std::time::SystemTime::now(), &config[1].0);
|
||||||
|
processes = parse_extern_config(&config[1].0);
|
||||||
|
}
|
||||||
// let processes: Processes = {
|
// let processes: Processes = {
|
||||||
// let mut _temp = String::new();
|
// let mut _temp = String::new();
|
||||||
// loop {
|
// loop {
|
||||||
|
|
@ -200,6 +211,10 @@ async fn main() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn save_new_config(config: &str) -> Result<(), CustomError> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn create_watcher(filename: &str, path: &str) -> Result<Inotify, std::io::Error> {
|
async fn create_watcher(filename: &str, path: &str) -> Result<Inotify, std::io::Error> {
|
||||||
let src = format!("{}{}", path, filename);
|
let src = format!("{}{}", path, filename);
|
||||||
let mut inotify: Inotify = Inotify::init().expect(&("Error: Cannot create watcher for ".to_owned() + &src));
|
let mut inotify: Inotify = Inotify::init().expect(&("Error: Cannot create watcher for ".to_owned() + &src));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue