+ env var for Noxis socket
parent
d6d45fe4aa
commit
895dc34557
|
|
@ -9,4 +9,5 @@ NOXIS_HAGENT_SOCKET_PATH = "/var/run/example/hostagent.sock"
|
|||
NOXIS_LOG_TO = "/var/log/noxis/noxis.log"
|
||||
NOXIS_REMOTE_SERVER_URL = "ip.ip.ip.ip:port"
|
||||
NOXIS_CONFIG_PATH = "./settings.json"
|
||||
NOXIS_METRICS_MODE = "full"
|
||||
NOXIS_METRICS_MODE = "full"
|
||||
NOXIS_SOCKET_PATH = "/path/to/noxis.sock"
|
||||
|
|
@ -20,8 +20,8 @@ use metrics::init_metrics_grubber;
|
|||
|
||||
#[tokio::main(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn main() -> anyhow::Result<()>{
|
||||
init_metrics_grubber().await;
|
||||
todo!();
|
||||
// init_metrics_grubber().await;
|
||||
// todo!();
|
||||
|
||||
let preboot = Arc::new(PrebootParams::validate());
|
||||
let _ = setup_logger();
|
||||
|
|
@ -33,19 +33,21 @@ async fn main() -> anyhow::Result<()>{
|
|||
let (tx_oneshot, rx_oneshot) = oneshot::channel::<Processes>();
|
||||
let mut handler: Vec<tokio::task::JoinHandle<()>> = vec![];
|
||||
|
||||
// initilaizing task for config manipulations
|
||||
// initilaizing task for config manipulations
|
||||
let preboot_config = preboot.clone();
|
||||
let config_module = tokio::spawn(async move {
|
||||
let _ = init_config_mechanism(
|
||||
rx_oneshot,
|
||||
tx_brd,
|
||||
preboot.clone()
|
||||
preboot_config
|
||||
).await;
|
||||
});
|
||||
handler.push(config_module);
|
||||
|
||||
// initilaizing task for cli manipulation
|
||||
let preboot_cli = preboot.clone();
|
||||
let cli_module = tokio::spawn(async move {
|
||||
if let Err(er) = init_cli_pipeline().await {
|
||||
if let Err(er) = init_cli_pipeline(preboot_cli).await {
|
||||
error!("CLI pipeline failed due to {}", er)
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@ use log::{error, info};
|
|||
use tokio::net::{ UnixStream, UnixListener };
|
||||
use tokio::time::{sleep, Duration};
|
||||
use std::fs;
|
||||
use std::sync::Arc;
|
||||
use tokio::io::{ AsyncWriteExt, AsyncReadExt};
|
||||
use noxis_cli::Cli;
|
||||
|
||||
use super::preboot::PrebootParams;
|
||||
|
||||
/// # Fn `init_cli_pipeline`
|
||||
/// ## for catching all input requests from CLI
|
||||
///
|
||||
|
|
@ -18,14 +21,15 @@ use noxis_cli::Cli;
|
|||
///
|
||||
/// *depends on* : -
|
||||
///
|
||||
pub async fn init_cli_pipeline() -> anyhow::Result<()> {
|
||||
let socket_path = "noxis.sock";
|
||||
pub async fn init_cli_pipeline(params: Arc<PrebootParams>) -> anyhow::Result<()> {
|
||||
let socket_path = ¶ms.self_socket;
|
||||
let _ = fs::remove_file(socket_path);
|
||||
|
||||
match UnixListener::bind(socket_path) {
|
||||
Ok(list) => {
|
||||
// TODO: remove `unwrap`s
|
||||
info!("Listening on {}", socket_path);
|
||||
info!("Listening on {}", socket_path.display());
|
||||
std::env::set_var("NOXIS_SOCKET_PATH", socket_path);
|
||||
loop {
|
||||
match list.accept().await {
|
||||
Ok((socket, _)) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue