allow port env
This commit is contained in:
parent
7ae392ad76
commit
c3d4afe71e
1 changed files with 8 additions and 1 deletions
|
@ -13,6 +13,7 @@ use tracing::{error, info, metadata::LevelFilter};
|
|||
use tracing_subscriber::{
|
||||
filter::filter_fn, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, Layer,
|
||||
};
|
||||
use std::env;
|
||||
use types::extract::RequestIp;
|
||||
|
||||
use crate::public::docs;
|
||||
|
@ -73,7 +74,13 @@ async fn main() {
|
|||
.layer(CookieManagerLayer::new())
|
||||
.layer(DefaultBodyLimit::max(512_000));
|
||||
|
||||
let Ok(addr) = "[::]:8080".parse::<std::net::SocketAddr>() else {
|
||||
let port: u16 = env::var("PORT")
|
||||
.unwrap_or_else(|_| String::new())
|
||||
.parse::<u16>()
|
||||
.unwrap_or(8080);
|
||||
|
||||
let Ok(addr) = format!("[::]:{port}")
|
||||
.parse::<std::net::SocketAddr>() else {
|
||||
error!("Failed to parse port binding");
|
||||
exit(1)
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue