From 7edf9e3f428dc1bd07559d07727776c46be9b8fc Mon Sep 17 00:00:00 2001 From: Andrew Fernandes Date: Sat, 9 Mar 2024 16:23:56 -0500 Subject: [PATCH 1/2] Make server port configurable through environment variable LK_JWT_PORT, default 8080 --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 29ef463..61afe61 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ import ( "context" "encoding/json" "errors" + "fmt" "log" "net/http" "os" @@ -174,6 +175,11 @@ func main() { log.Fatal("LIVEKIT_KEY, LIVEKIT_SECRET and LIVEKIT_URL environment variables must be set") } + lk_jwt_port := os.Getenv("LK_JWT_PORT") + if lk_jwt_port == "" { + lk_jwt_port = "8080" + } + log.Printf("LIVEKIT_KEY: %s and LIVEKIT_SECRET %s, LIVEKIT_URL %s", key, secret, lk_url) handler := &Handler{ @@ -185,7 +191,7 @@ func main() { http.HandleFunc("/sfu/get", handler.handle) http.HandleFunc("/healthz", handler.healthcheck) - log.Fatal(http.ListenAndServe(":8080", nil)) + log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", lk_jwt_port), nil)) } func getJoinToken(apiKey, apiSecret, room, identity string) (string, error) { From 2678af665092e8e74c72e8e917249715c06e671d Mon Sep 17 00:00:00 2001 From: Andrew Fernandes Date: Thu, 14 Mar 2024 07:32:27 -0400 Subject: [PATCH 2/2] Update readme to reflect usage of LK_JWT_PORT environment variable --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 11d0146..f4676a5 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,5 @@ To start the service locally: ``` $ LIVEKIT_URL="ws://somewhere" LIVEKIT_KEY=devkey LIVEKIT_SECRET=secret go run *.go ``` + +The listening port is configurable via the `LK_JWT_PORT` environment variable. \ No newline at end of file