diff --git a/server/.env.example b/server/.env.example index 495fc67..e679f3f 100644 --- a/server/.env.example +++ b/server/.env.example @@ -1,2 +1,3 @@ DATABASE_URL=postgres://thermit-server:thermit-server@localhost/thermit-server -SERVER_PORT=8000 \ No newline at end of file +SERVER_IP=0.0.0.0 +SERVER_PORT=8000 diff --git a/server/README.md b/server/README.md index 8cf3fbc..bc58248 100644 --- a/server/README.md +++ b/server/README.md @@ -13,4 +13,6 @@ We use a postgres database. You can find a configuration in the docker/postgres. To interact with the database, use Diesel. To install use `cargo install diesel_cli --no-default-features --features postgres`. -Run migrations with `diesel migration run`. +With Diesel installed, you can run migrations with `diesel migration run`. This will create the needed tables. + +To start the server, a `.env` file must be created that contains some settings. You can find an example in `.env.example`. diff --git a/server/src/main.rs b/server/src/main.rs index fc97551..2623638 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -24,9 +24,10 @@ async fn main() -> std::io::Result<()> { .build(manager) .expect("Failed to create pool."); + let server_ip = std::env::var("SERVER_IP").expect("SERVER_IP must be set"); let server_port = std::env::var("SERVER_PORT").expect("SERVER_PORT must be set"); - let mut server_address = "0.0.0.0:".to_string(); - server_address.push_str(&server_port[..]); + + let server_address = format!("{}:{}", server_ip, server_port); HttpServer::new(move || { App::new()