mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2025-07-05 02:14:17 +00:00
use HTTP_PORT env var for webserver port. Defaults to 80 now
This commit is contained in:
parent
c91ec8076e
commit
727d801849
@ -1,9 +1,10 @@
|
|||||||
use log::{error, info};
|
use log::{error, info, warn};
|
||||||
use rocket::http::Status;
|
use rocket::http::Status;
|
||||||
use rocket::{Config, State};
|
use rocket::{Config, State};
|
||||||
use rocket::{get, http::ContentType, response::content::RawHtml, routes};
|
use rocket::{get, http::ContentType, response::content::RawHtml, routes};
|
||||||
use rust_embed::Embed;
|
use rust_embed::Embed;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::env;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
@ -15,9 +16,17 @@ use crate::id_store::IDStore;
|
|||||||
struct Asset;
|
struct Asset;
|
||||||
|
|
||||||
pub async fn start_webserver(store: Arc<Mutex<IDStore>>) -> Result<(), rocket::Error> {
|
pub async fn start_webserver(store: Arc<Mutex<IDStore>>) -> Result<(), rocket::Error> {
|
||||||
|
let port = match env::var("HTTP_PORT") {
|
||||||
|
Ok(port) => port.parse().unwrap_or_else(|_| {
|
||||||
|
warn!("Failed to parse HTTP_PORT. Using default 80");
|
||||||
|
80
|
||||||
|
}),
|
||||||
|
Err(_) => 80,
|
||||||
|
};
|
||||||
|
|
||||||
let config = Config {
|
let config = Config {
|
||||||
address: "0.0.0.0".parse().unwrap(), // Listen on all interfaces
|
address: "0.0.0.0".parse().unwrap(), // Listen on all interfaces
|
||||||
port: 8000,
|
port,
|
||||||
..Config::default()
|
..Config::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user