From ce1f80cd4f367edf01f183a22e6a79095ed6bfb0 Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Fri, 26 Apr 2024 14:16:53 +0200 Subject: [PATCH] shuttle: add dotenvy for handling envvars --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/main.rs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 64d0f34..6bdc7c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -415,6 +415,7 @@ dependencies = [ "base64 0.22.0", "clap 4.5.4", "dotenv", + "dotenvy", "flume", "futures-util", "headers", @@ -730,6 +731,12 @@ dependencies = [ "clap 2.34.0", ] +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + [[package]] name = "ecdsa" version = "0.16.9" diff --git a/Cargo.toml b/Cargo.toml index 12d3e69..87d6462 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ headers = "0.4" tower = { version = "0.4", features = ["util"] } shuttle-axum = { version = "0.44.0", optional = true } shuttle-runtime = { version = "0.44.0", optional = true } +dotenvy = "0.15.7" [build-dependencies] prost-build = "0.12.4" diff --git a/src/main.rs b/src/main.rs index 3570e48..bef999b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,9 @@ use crate::cli::args::Args; +#[cfg(not(feature = "shuttle"))] use dotenv::dotenv; #[cfg(feature = "shuttle")] +use dotenvy::dotenv; +#[cfg(feature = "shuttle")] use shuttle_axum::ShuttleAxum; use tracing::error; #[cfg(not(feature = "shuttle"))] @@ -43,6 +46,7 @@ async fn main() -> Result<(), Box> { #[cfg(feature = "shuttle")] #[shuttle_runtime::main] async fn main() -> ShuttleAxum { + dotenv().ok(); let app_host = env::var("APP_HOST").unwrap_or("0.0.0.0".to_string()); let app_port = env::var("APP_PORT").unwrap_or("8000".to_string());