Skip to content

Commit

Permalink
Add server ip to .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
frcroth committed Feb 28, 2021
1 parent e34d7f8 commit 646632f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion server/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DATABASE_URL=postgres://thermit-server:thermit-server@localhost/thermit-server
SERVER_PORT=8000
SERVER_IP=0.0.0.0
SERVER_PORT=8000
4 changes: 3 additions & 1 deletion server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
5 changes: 3 additions & 2 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 646632f

Please sign in to comment.