get port from env

This commit is contained in:
Franz Dietrich 2023-02-05 11:53:26 +01:00
parent 9adcb1619a
commit 5a45099e7b
Signed by: dietrich
GPG Key ID: F0CE5A20AB5C4B27
2 changed files with 6 additions and 2 deletions

2
.env
View File

@ -2,5 +2,5 @@ DATABASE_URL="sqlite://terminwahl_back/db.sqlite"
RUST_LOG="debug" RUST_LOG="debug"
SMTP_USER="SMTP_USERNAME" SMTP_USER="SMTP_USERNAME"
SMTP_PASSWORD="SMTP_PASSWORD" SMTP_PASSWORD="SMTP_PASSWORD"
PORT="8087"
PATH_TO_STATICS="terminwahl_front/dist/" PATH_TO_STATICS="terminwahl_front/dist/"

View File

@ -25,6 +25,10 @@ async fn main() -> std::io::Result<()> {
let smtp_user = env::var("SMTP_USER").expect("Failed to get smtp user"); let smtp_user = env::var("SMTP_USER").expect("Failed to get smtp user");
let smtp_password = env::var("SMTP_PASSWORD").expect("Failed to get smtp password"); let smtp_password = env::var("SMTP_PASSWORD").expect("Failed to get smtp password");
let wasm_statics = env::var("PATH_TO_STATICS").expect("Failed to get statics path"); let wasm_statics = env::var("PATH_TO_STATICS").expect("Failed to get statics path");
let port: u16 = env::var("PORT")
.expect("Failed to get port")
.parse()
.expect("Not a Portnumber");
let credentials = Credentials::new(smtp_user, smtp_password); let credentials = Credentials::new(smtp_user, smtp_password);
let smtp_pool = SmtpTransport::relay("smtp.1und1.de") let smtp_pool = SmtpTransport::relay("smtp.1und1.de")
.expect("Failed to connect to smtp") .expect("Failed to connect to smtp")
@ -88,7 +92,7 @@ async fn main() -> std::io::Result<()> {
) )
.service(Files::new("/", wasm_statics.clone()).index_file("index.html")) .service(Files::new("/", wasm_statics.clone()).index_file("index.html"))
}) })
.bind(("127.0.0.1", 8080))? .bind(("127.0.0.1", port))?
.workers(2) .workers(2)
.run() .run()
.await .await