Add config option for http listen address

This commit is contained in:
Brian Picciano 2023-05-12 11:17:15 +02:00
parent 21b5b99022
commit a3c41ee4d6

View File

@ -4,12 +4,17 @@ use signal_hook::consts::signal;
use signal_hook_tokio::Signals; use signal_hook_tokio::Signals;
use tokio::sync::oneshot; use tokio::sync::oneshot;
use std::net::SocketAddr;
use std::path; use std::path;
use std::str::FromStr;
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
#[command(version)] #[command(version)]
#[command(about = "A gateway to another dimension")] #[command(about = "A gateway to another dimension")]
struct Cli { 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")] #[arg(long, required = true, env = "GATEWAY_ORIGIN_STORE_GIT_DIR_PATH")]
origin_store_git_dir_path: Option<path::PathBuf>, origin_store_git_dir_path: Option<path::PathBuf>,
@ -68,7 +73,7 @@ async fn main() {
let service = gateway::service::new(manager).expect("service initialized"); let service = gateway::service::new(manager).expect("service initialized");
let (addr, server) = 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(); stop_ch_rx.await.ok();
}); });