add listen port

This commit is contained in:
Martin Brodbeck 2025-01-08 15:06:57 +01:00
parent 3374110f38
commit ab444e07f4
2 changed files with 5 additions and 2 deletions

View file

@ -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();

View file

@ -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]