From ec65114b4aee6e5d18b4fa9f761bea6ba4b27081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CGiems=E2=80=9D?= <“hubert.wabia@gmail.com”> Date: Wed, 6 Mar 2024 13:57:14 +0100 Subject: [PATCH] fix env --- .env | 2 +- server/src/bin/nightly-connect-server.rs | 2 -- server/src/env.rs | 5 ++--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.env b/.env index 1d417f8b..5d75d99c 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ ENV=DEV # PROD or DEV -ONLY_RELAY_SERVICE=TRUE # TRUE - This will start only nightly relay service without cloud service +ONLY_RELAY_SERVICE=True # TRUE - This will start only nightly relay service without cloud service NONCE=VERY_SECRET_NONCE JWT_SECRET=VERY_SECRET_SECRET diff --git a/server/src/bin/nightly-connect-server.rs b/server/src/bin/nightly-connect-server.rs index 6ea503dd..0693435a 100644 --- a/server/src/bin/nightly-connect-server.rs +++ b/server/src/bin/nightly-connect-server.rs @@ -5,8 +5,6 @@ use std::sync::mpsc::channel; #[tokio::main] async fn main() { - dotenvy::dotenv().expect(".env file not found"); - let router = get_router(ONLY_RELAY_SERVICE()).await; let listener = tokio::net::TcpListener::bind(&"127.0.0.1:6969") .await diff --git a/server/src/env.rs b/server/src/env.rs index 2d433121..5a6c9a0b 100644 --- a/server/src/env.rs +++ b/server/src/env.rs @@ -14,7 +14,7 @@ pub fn get_env() -> &'static ENV { INSTANCE.get_or_init(|| { dotenvy::from_filename(".env").ok(); - let ENVIRONMENT = std::env::var("ENVIRONMENT").expect("Failed to get ENVIRONMENT env"); + let ENVIRONMENT = std::env::var("ENV").expect("Failed to get ENV env"); let ENVIRONMENT = ENVIRONMENT.as_str(); let env = ENV { @@ -35,8 +35,7 @@ pub fn get_env() -> &'static ENV { }, ONLY_RELAY_SERVICE: std::env::var("ONLY_RELAY_SERVICE") .expect("Failed to get ONLY_RELAY_SERVICE env") - .parse() - .expect("Failed to parse ONLY_RELAY_SERVICE env"), + .eq_ignore_ascii_case("true"), NONCE: std::env::var("NONCE").expect("Failed to get NONCE env"), }; return env;