From: fozzie Date: Fri, 18 Jul 2025 23:54:16 +0000 (-0500) Subject: Allow .env to be missing X-Git-Url: https://git.humopery.space/?a=commitdiff_plain;h=5f31da7d43ffd41a474589fb7287f000526e90e0;p=waterslager.git Allow .env to be missing --- diff --git a/.env b/.env index 1237571..3015b73 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -BIND_HOST=127.0.0.1 -BIND_PORT=3000 +# BIND_HOST=127.0.0.1 +# BIND_PORT=3000 diff --git a/src/main.rs b/src/main.rs index 6f949b6..ded6233 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,12 +38,13 @@ async fn load_certs_from_fs() -> Result> { #[tokio::main] async fn main() -> Result<(),Box> { - // Set default config values, then override with .env + // Set config from .env, ignoring any error (file may not be there) + let _ = dotenvy::dotenv(); + // ... then override with defaults unsafe { env::set_var("BIND_HOST","127.0.0.1"); env::set_var("BIND_PORT","3000"); } - dotenvy::dotenv_override()?; let certs = load_certs_from_fs().await.unwrap();