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