changed config load

This commit is contained in:
2025-08-28 18:25:19 +02:00
parent a555396e2a
commit c4a2e1acf7
2 changed files with 4 additions and 12 deletions

View File

@@ -1,14 +1,6 @@
use config::Config;
use serde::Deserialize;
use crate::models::WatcherConfig; use crate::models::WatcherConfig;
#[derive(Debug, Deserialize, Clone)] impl WatcherConfig {
pub struct AppConfig {
pub watcher: WatcherConfig,
}
impl AppConfig {
pub fn from_env() -> Result<Self, config::ConfigError> { pub fn from_env() -> Result<Self, config::ConfigError> {
// Load .env file (works in both Docker and local development) // Load .env file (works in both Docker and local development)
dotenvy::dotenv().ok(); dotenvy::dotenv().ok();

View File

@@ -7,7 +7,7 @@ pub mod hardware;
pub mod metrics; pub mod metrics;
pub mod models; pub mod models;
use config::AppConfig; use models::WatcherConfig;
use std::error::Error; use std::error::Error;
use std::marker::Send; use std::marker::Send;
@@ -27,8 +27,8 @@ async fn flatten<T>(
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> { async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
let config = AppConfig::from_env().expect("Failed to load configuration"); let config = WatcherConfig::from_env().expect("Failed to load configuration");
let server_url = config.watcher.server_url.clone(); let server_url = config.server_url.clone();
// Registration // 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 {