Fix unix config and refactor configs

This commit is contained in:
2023-05-31 21:57:01 +02:00
parent 276af0ba97
commit bfb550e5a6
4 changed files with 86 additions and 22 deletions

View File

@@ -3,7 +3,7 @@ use crate::server_conf::conexion::Conexion;
use crate::server_conf::listener::GenericListener;
use std::thread;
use std::sync::{Arc, RwLock};
use log::{error,info};
use log::{error,warn,info};
pub struct ConfSer{
path: String,
@@ -11,11 +11,17 @@ pub struct ConfSer{
}
impl ConfSer {
fn new(path: &String, conf_type: &String) -> ConfSer{
fn new(path: String, conf_type: &String) -> ConfSer{
ConfSer{
path: path.clone(),
listener: GenericListener::bind(path,
GenericListener::string_top_type(conf_type)).unwrap(),
listener: match GenericListener::bind(path,
GenericListener::string_top_type(conf_type)){
Ok(l) => l,
Err(e) => {
warn!("Error al levantar el servidor de configuraciones:{}",e);
panic!("Error al levantar el servidor de configuraciones:{}",e)
},
},
}
}
}
@@ -29,8 +35,10 @@ impl Drop for ConfSer {
}
pub fn start(conf: Arc<RwLock<conf::Config>>){
let ser = ConfSer::new(conf.read().unwrap().get_port_conf()
,conf.read().unwrap().get_conf_type());
let ser = ConfSer::new(
conf.read().unwrap().get_bindeable_conf(),
conf.read().unwrap().get_conf_type(),
);
loop{
match ser.listener.accept() {