config server now in settings.json
parent
8fa5533cdf
commit
40b0ba9e6e
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"dateOfCreation": "1721381809103",
|
||||
"configServer" : "localhost",
|
||||
"processes": [
|
||||
{
|
||||
"name": "web-server",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use std::os::unix::process::CommandExt;
|
|||
use std::process::Command;
|
||||
use std::sync::Arc;
|
||||
use std::{env, fs};
|
||||
use std::fmt::format;
|
||||
use tokio::time::Duration;
|
||||
|
||||
const CONFIG_PATH: &str = "settings.json";
|
||||
|
|
@ -29,7 +30,7 @@ pub fn get_actual_config() -> Option<Processes> {
|
|||
"Found local configuration, version - {}",
|
||||
&local_conf.date_of_creation
|
||||
);
|
||||
if let Some(remote_conf) = once_get_remote_configuration("redis://172.19.32.198:6379/") {
|
||||
if let Some(remote_conf) = once_get_remote_configuration(&format!("redis://{}/", local_conf.config_server)) {
|
||||
return match config_comparing(&local_conf, &remote_conf) {
|
||||
ConfigActuality::Local => {
|
||||
info!("Local config is actual");
|
||||
|
|
@ -48,7 +49,7 @@ pub fn get_actual_config() -> Option<Processes> {
|
|||
}
|
||||
None => {
|
||||
// ? ? OUTSTANDING CONSTRUCTION ?
|
||||
let mut conn = get_connection_watcher(&open_watcher("redis://localhost"));
|
||||
let mut conn = get_connection_watcher(&open_watcher("redis://localhost/"));
|
||||
get_stream_info_watcher(&mut conn);
|
||||
let remote_config = invalid_config_watcher(&mut conn);
|
||||
let _ = save_new_config(&remote_config, CONFIG_PATH);
|
||||
|
|
@ -195,7 +196,7 @@ fn restart_main_thread() -> std::io::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
pub async fn subscribe_config_stream(actual_prcs: Arc<Processes>) -> Result<(), CustomError> {
|
||||
if let Ok(client) = Client::open("redis://localhost") {
|
||||
if let Ok(client) = Client::open(format!("redis://{}/", &actual_prcs.config_server)) {
|
||||
if let Ok(mut conn) = client.get_connection() {
|
||||
info!("Runner subscribed on config update");
|
||||
loop {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ pub struct Processes {
|
|||
// runner_id: usize,
|
||||
#[serde(rename = "dateOfCreation")]
|
||||
pub date_of_creation: String,
|
||||
#[serde(rename = "configServer")]
|
||||
pub config_server: String,
|
||||
#[serde(default)]
|
||||
pub processes: Vec<TrackingProcess>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue