heroku reconfigured

This commit is contained in:
Víctor Martínez 2021-03-21 21:21:26 +01:00
parent 364e506166
commit 8f1d11fb24
3 changed files with 18 additions and 6 deletions

View file

@ -1 +0,0 @@
web: ./target/release/actix-messaging

5
heroku.yml Normal file
View file

@ -0,0 +1,5 @@
build:
docker:
web: Dockerfile
run:
web: ./actix-messaging

View file

@ -6,20 +6,28 @@ mod routes;
use crate::{actors::chat_server::ChatServer, models::AppState};
use actix::Actor;
use actix_web::{App, HttpServer};
use actix_web::{App, HttpServer, get};
use routes::connect;
#[get("/hi")]
async fn hi() -> &'static str {
"Hello, World!"
}
fn get_server_addr() -> String {
let port = std::env::var("PORT").expect("PORT env variable not found");
format!("127.0.0.1:{}", port)
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let port = std::env::var("PORT").expect("PORT env variable not found");
let addr = format!("127.0.0.1:{}", port);
let addr = get_server_addr();
let chat = ChatServer::new().start();
HttpServer::new(move || {
App::new()
.data(AppState { chat: chat.clone() })
.service(connect)
.service(hi)
})
.bind(&addr)?
.run()