preboot settings added
parent
bda4762713
commit
591a1df5d6
|
|
@ -13,6 +13,7 @@ debug = false
|
|||
[dependencies]
|
||||
anyhow = "1.0.93"
|
||||
chrono = "0.4.38"
|
||||
clap = { version = "4.5.21", features = ["derive"] }
|
||||
env_logger = "0.11.3"
|
||||
inotify = "0.10.2"
|
||||
log = "0.4.22"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
mod options;
|
||||
mod utils;
|
||||
|
||||
use clap::Parser;
|
||||
use log::{error, info};
|
||||
use options::config::*;
|
||||
use options::logger::setup_logger;
|
||||
|
|
@ -10,9 +11,15 @@ use std::sync::Arc;
|
|||
use std::time::Duration;
|
||||
use tokio::sync::mpsc;
|
||||
use utils::*;
|
||||
use options::preboot::*;
|
||||
|
||||
#[tokio::main(flavor = "multi_thread")]
|
||||
async fn main() {
|
||||
use options::structs::PrebootParams;
|
||||
let a = PrebootParams::parse();
|
||||
println!("{:?}", a);
|
||||
|
||||
|
||||
let _ = setup_logger();
|
||||
|
||||
info!("Runner is configurating...");
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@ pub mod config;
|
|||
pub mod logger;
|
||||
pub mod signals;
|
||||
pub mod structs;
|
||||
pub mod preboot;
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// module to handle pre-boot params of the monitor
|
||||
use super::structs::PrebootParams;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// unit tests of prebot params parsing mech
|
||||
|
|
@ -2,11 +2,63 @@
|
|||
|
||||
use std::net::Ipv4Addr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use clap::Parser;
|
||||
|
||||
/// # an Error enum (next will be deleted and replaced)
|
||||
pub enum CustomError {
|
||||
Fatal,
|
||||
}
|
||||
|
||||
#[derive(clap::ValueEnum, Debug, Clone)]
|
||||
enum MetricsPrebootParams {
|
||||
Full,
|
||||
System,
|
||||
Processes,
|
||||
Net,
|
||||
None,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for MetricsPrebootParams {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
MetricsPrebootParams::Full => write!(f, "full"),
|
||||
MetricsPrebootParams::System => write!(f, "system"),
|
||||
MetricsPrebootParams::Processes => write!(f, "processes"),
|
||||
MetricsPrebootParams::Net => write!(f, "net"),
|
||||
MetricsPrebootParams::None => write!(f, "none"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
pub struct PrebootParams {
|
||||
// actions
|
||||
#[arg(long = "no-hagent", action, conflicts_with="socket_path", help="To disable work with host-agent")]
|
||||
no_hostagent : bool,
|
||||
#[arg(long = "no-logs", action, conflicts_with="log_to", help="To disable logs")]
|
||||
no_logs: bool,
|
||||
#[arg(long = "refresh-logs", action, conflicts_with="no_logs", help="To clear logs directory")]
|
||||
refresh_logs : bool,
|
||||
#[arg(long = "no-remote-config", action, help="To disable work with remote config server", conflicts_with="no_sub")]
|
||||
no_remote_config : bool,
|
||||
#[arg(long = "no-sub", action, help="To disable subscription mechanism", conflicts_with="no_remote_config")]
|
||||
no_sub : bool,
|
||||
|
||||
// params (socket_path, log_to, remote_server_url, config)
|
||||
#[arg(long = "socket-path", default_value=None, conflicts_with="no_hostagent", help="To set .sock file's path used in communication with host-agent")]
|
||||
socket_path : Option<String>,
|
||||
#[arg(long = "log-to", default_value=None, conflicts_with="no_logs", help="To set a path to logs directory")]
|
||||
log_to : Option<String>,
|
||||
#[arg(long = "remote-server-url", default_value="redis://localhost", conflicts_with="no_remote_config", help = "To set url of remote config server using in remote config pulling mechanism")]
|
||||
remote_server_url : String,
|
||||
#[arg(long = "config", short, default_value="settings.json", help="To set local config file path")]
|
||||
config : String,
|
||||
|
||||
// value enum params (metrics)
|
||||
#[arg(long = "metrics", short, default_value_t=MetricsPrebootParams::Full, help="To set metrics grubbing mode")]
|
||||
metrics: MetricsPrebootParams,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ConfigActuality {
|
||||
Local,
|
||||
|
|
|
|||
Loading…
Reference in New Issue