From a3c41ee4d6cfae72f2cab4bff4345e011a5bcacb Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Fri, 12 May 2023 11:17:15 +0200 Subject: [PATCH] Add config option for http listen address --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e0af841..2b74e13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,12 +4,17 @@ use signal_hook::consts::signal; use signal_hook_tokio::Signals; use tokio::sync::oneshot; +use std::net::SocketAddr; use std::path; +use std::str::FromStr; #[derive(Parser, Debug)] #[command(version)] #[command(about = "A gateway to another dimension")] struct Cli { + #[arg(long, default_value_t = SocketAddr::from_str("127.0.0.1:3030").unwrap(), env = "GATEWAY_HTTP_LISTEN_ADDR")] + http_listen_addr: SocketAddr, + #[arg(long, required = true, env = "GATEWAY_ORIGIN_STORE_GIT_DIR_PATH")] origin_store_git_dir_path: Option, @@ -68,7 +73,7 @@ async fn main() { let service = gateway::service::new(manager).expect("service initialized"); let (addr, server) = - warp::serve(service).bind_with_graceful_shutdown(([127, 0, 0, 1], 3030), async { + warp::serve(service).bind_with_graceful_shutdown(config.http_listen_addr, async { stop_ch_rx.await.ok(); });