diff --git a/src/main.rs b/src/main.rs index dadab76..bbf116f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,6 +47,7 @@ async fn main() { .ok() .and_then(|v| v.parse().ok()) .unwrap(); + let listen_port: String = env::var("PORT").ok().and_then(|v| v.parse().ok()).unwrap(); let db_pool = PgPoolOptions::new() .max_connections(64) @@ -66,8 +67,9 @@ async fn main() { .route("/version", get(version)) .with_state(db_pool); - // run it with hyper on localhost:3003 - let listener = tokio::net::TcpListener::bind("127.0.0.1:3003") + let mut bind_with = "127.0.0.1:".to_owned(); + bind_with += &listen_port; + let listener = tokio::net::TcpListener::bind(bind_with) .await .unwrap(); axum::serve(listener, app).await.unwrap(); diff --git a/systemd/kosyncrs.service b/systemd/kosyncrs.service index b405332..1809f9a 100644 --- a/systemd/kosyncrs.service +++ b/systemd/kosyncrs.service @@ -12,6 +12,7 @@ Group=users WorkingDirectory=/home/myuser ExecStart=/usr/local/bin/kosyncrs Environment="PG_URL=postgresql://kosync:password@localhost/kosync" +Environment="PORT=3003" Restart=always [Install]