Skip to content

Commit

Permalink
feat: allow configuring port and interface
Browse files Browse the repository at this point in the history
  • Loading branch information
lajp committed Aug 11, 2024
1 parent 779331f commit 143e593
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ async fn main() {

let state = state::new().await;

let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
let ip = if std::env::var("EXPOSE").unwrap_or("0".into()) == "1" {
[0, 0, 0, 0]
} else {
[127, 0, 0, 1]
};

let addr = SocketAddr::from((
ip,
std::env::var("PORT")
.map(|p| p.parse::<u16>().unwrap())
.unwrap_or(3000),
));
debug!("Listening on {addr}");
let listener = tokio::net::TcpListener::bind(addr)
.await
Expand Down

0 comments on commit 143e593

Please sign in to comment.