diff --git a/adapter/rest/src/main.rs b/adapter/rest/src/main.rs index 44852b0..c2dfa00 100644 --- a/adapter/rest/src/main.rs +++ b/adapter/rest/src/main.rs @@ -55,12 +55,17 @@ impl IdentifiableFlow for RequestRoute { #[async_trait] impl ServerTrait for HttpServer { async fn init(&mut self, ctx: &ServerContext) -> anyhow::Result<()> { - self.http_server = Some(Server::new(ctx.server_config.port)); + log::info!("Initializing http server"); + self.http_server = Some(Server::new( + ctx.server_config.host.clone(), + ctx.server_config.port, + )); Ok(()) } async fn run(&mut self, ctx: &ServerContext) -> anyhow::Result<()> { if let Some(server) = &mut self.http_server { + log::info!("Running http server"); server.register_async_closure({ let store = Arc::clone(&ctx.adapter_store); move |request: HttpRequest| { @@ -163,12 +168,14 @@ async fn execute_flow( #[derive(Clone)] struct HttpServerConfig { port: u16, + host: String, } impl LoadConfig for HttpServerConfig { fn load() -> Self { Self { port: env_with_default("HTTP_SERVER_PORT", 8082), + host: env_with_default("HTTP_SERVER_HOST", String::from("0.0.0.0")), } } } diff --git a/crates/http/src/server.rs b/crates/http/src/server.rs index 408ff73..0c22a78 100644 --- a/crates/http/src/server.rs +++ b/crates/http/src/server.rs @@ -27,14 +27,16 @@ where } pub struct Server { + host: String, port: u16, handlers: Arc>>, shutdown_tx: Option>, } impl Server { - pub fn new(port: u16) -> Self { + pub fn new(host: String, port: u16) -> Self { Server { + host, port, handlers: Arc::new(Vec::new()), shutdown_tx: None, @@ -74,8 +76,8 @@ impl Server { } async fn run_server(&self, shutdown_rx: &mut tokio::sync::broadcast::Receiver<()>) { - let url = format!("127.0.0.1:{}", self.port); - + let url = format!("{}:{}", self.host, self.port); + log::info!("Starting http server on {}", &url); let listener = match TcpListener::bind(&url) { Ok(listener) => { listener