summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelonai <einebeere@gmail.com>2020-05-08 22:04:36 +0200
committerMelonai <einebeere@gmail.com>2020-05-08 22:04:36 +0200
commit8ed78fbfeee137bb4f638eccf184a0ededc24f61 (patch)
treeeb14094260419509591ada01796ab636aa62f7c3
parent0740af5161ef0ef2322eb44d81cd00fc5ffee9fa (diff)
downloadshorest-8ed78fbfeee137bb4f638eccf184a0ededc24f61.tar.zst
shorest-8ed78fbfeee137bb4f638eccf184a0ededc24f61.zip
port setting added
-rw-r--r--src/main.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 9e6bef1..72f1cad 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -15,7 +15,6 @@ use diesel::r2d2::{ConnectionManager, Pool};
use actix_files::{Files, NamedFile};
fn establish_connection() -> Pool<ConnectionManager<PgConnection>> {
- dotenv().ok();
let database_url = std::env::var("DATABASE_URL").expect("Cannot find DATABASE_URL. Check .env file.");
let manager = ConnectionManager::<PgConnection>::new(database_url);
Pool::builder().max_size(4).build(manager).expect("Failed to create pool.")
@@ -94,10 +93,15 @@ async fn redirect(info: Path<String>, state: Data<PoolState>) -> HttpResponse {
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
+ dotenv().ok();
std::env::set_var("RUST_LOG", "actix_web=info");
env_logger::init();
let pool = establish_connection();
+ let port = std::env::var("PORT")
+ .unwrap()
+ .parse()
+ .expect("PORT must be a number.");
HttpServer::new(move || {
App::new()
@@ -116,7 +120,7 @@ async fn main() -> std::io::Result<()> {
Files::new("/static/", "./client/static/")
)
})
- .bind("localhost:3000")?
+ .bind(("0.0.0.0", port))?
.run()
.await
}