wip(inventory-agent): local presence advertisement and discovery using mdns almost working
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
// src/main.rs
|
||||
use actix_web::{App, HttpServer, Responder, get};
|
||||
use hwinfo::PhysicalHost;
|
||||
use log::error;
|
||||
use std::env;
|
||||
|
||||
use crate::hwinfo::PhysicalHost;
|
||||
|
||||
mod hwinfo;
|
||||
mod local_presence;
|
||||
|
||||
|
||||
|
||||
|
||||
#[get("/inventory")]
|
||||
async fn inventory() -> impl Responder {
|
||||
@@ -26,10 +32,15 @@ async fn main() -> std::io::Result<()> {
|
||||
env_logger::init();
|
||||
|
||||
let port = env::var("HARMONY_INVENTORY_AGENT_PORT").unwrap_or_else(|_| "8080".to_string());
|
||||
let port = port.parse::<u16>().expect(&format!("Invalid port number, cannot parse to u16 {port}"));
|
||||
let bind_addr = format!("0.0.0.0:{}", port);
|
||||
|
||||
log::info!("Starting inventory agent on {}", bind_addr);
|
||||
|
||||
if let Err(e) = local_presence::advertise(port) {
|
||||
error!("Could not start advertise local presence : {e}");
|
||||
}
|
||||
|
||||
HttpServer::new(|| App::new().service(inventory))
|
||||
.bind(&bind_addr)?
|
||||
.run()
|
||||
|
||||
Reference in New Issue
Block a user