Skip to content

Commit

Permalink
Make server port configurable through environment variable LK_JWT_POR…
Browse files Browse the repository at this point in the history
…T, default 8080 (#17)

* Make server port configurable through environment variable LK_JWT_PORT, default 8080

* Update readme to reflect usage of LK_JWT_PORT environment variable
  • Loading branch information
rockaport authored Mar 19, 2024
1 parent 186cc20 commit 94fa50e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -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{
Expand All @@ -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) {
Expand Down

0 comments on commit 94fa50e

Please sign in to comment.