File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -55,12 +55,17 @@ impl IdentifiableFlow for RequestRoute {
5555#[ async_trait]
5656impl ServerTrait < HttpServerConfig > for HttpServer {
5757 async fn init ( & mut self , ctx : & ServerContext < HttpServerConfig > ) -> anyhow:: Result < ( ) > {
58- self . http_server = Some ( Server :: new ( ctx. server_config . port ) ) ;
58+ log:: info!( "Initializing http server" ) ;
59+ self . http_server = Some ( Server :: new (
60+ ctx. server_config . host . clone ( ) ,
61+ ctx. server_config . port ,
62+ ) ) ;
5963 Ok ( ( ) )
6064 }
6165
6266 async fn run ( & mut self , ctx : & ServerContext < HttpServerConfig > ) -> anyhow:: Result < ( ) > {
6367 if let Some ( server) = & mut self . http_server {
68+ log:: info!( "Running http server" ) ;
6469 server. register_async_closure ( {
6570 let store = Arc :: clone ( & ctx. adapter_store ) ;
6671 move |request : HttpRequest | {
@@ -163,12 +168,14 @@ async fn execute_flow(
163168#[ derive( Clone ) ]
164169struct HttpServerConfig {
165170 port : u16 ,
171+ host : String ,
166172}
167173
168174impl LoadConfig for HttpServerConfig {
169175 fn load ( ) -> Self {
170176 Self {
171177 port : env_with_default ( "HTTP_SERVER_PORT" , 8082 ) ,
178+ host : env_with_default ( "HTTP_SERVER_HOST" , String :: from ( "0.0.0.0" ) ) ,
172179 }
173180 }
174181}
Original file line number Diff line number Diff line change @@ -27,14 +27,16 @@ where
2727}
2828
2929pub struct Server {
30+ host : String ,
3031 port : u16 ,
3132 handlers : Arc < Vec < Box < dyn AsyncHandler > > > ,
3233 shutdown_tx : Option < tokio:: sync:: broadcast:: Sender < ( ) > > ,
3334}
3435
3536impl Server {
36- pub fn new ( port : u16 ) -> Self {
37+ pub fn new ( host : String , port : u16 ) -> Self {
3738 Server {
39+ host,
3840 port,
3941 handlers : Arc :: new ( Vec :: new ( ) ) ,
4042 shutdown_tx : None ,
@@ -74,8 +76,8 @@ impl Server {
7476 }
7577
7678 async fn run_server ( & self , shutdown_rx : & mut tokio:: sync:: broadcast:: Receiver < ( ) > ) {
77- let url = format ! ( "127.0.0.1 :{}" , self . port) ;
78-
79+ let url = format ! ( "{} :{}" , self . host , self . port) ;
80+ log :: info! ( "Starting http server on {}" , & url ) ;
7981 let listener = match TcpListener :: bind ( & url) {
8082 Ok ( listener) => {
8183 listener
You can’t perform that action at this time.
0 commit comments