added .env readability

This commit is contained in:
2025-08-11 21:33:19 +02:00
parent df36cb53c7
commit 9e851c310c
5 changed files with 40 additions and 20 deletions

View File

@@ -2,11 +2,13 @@
/// This agent collects hardware metrics and sends them to a backend server.
/// It supports CPU, GPU, RAM, disk, and network metrics.
pub mod api;
pub mod config;
pub mod hardware;
pub mod metrics;
pub mod models;
pub use crate::hardware::gpu;
use config::AppConfig;
use std::error::Error;
use std::marker::Send;
use std::marker::Sync;
@@ -25,10 +27,11 @@ async fn flatten<T>(
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
let server_url = "http://localhost:5000";
let config = AppConfig::from_env().expect("Failed to load configuration");
let server_url = config.watcher.server_url.clone();
// Registration
let (server_id, ip) = match api::register_with_server(server_url).await {
let (server_id, ip) = match api::register_with_server(&server_url).await {
Ok((id, ip)) => (id, ip),
Err(e) => {
eprintln!("Fehler bei der Registrierung am Server: {e}");