Skip to content

Commit ddd90fd

Browse files
authored
fix issues with port loading from config (#1464)
1 parent efc7efd commit ddd90fd

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

backend/config/config.go

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package config
22

33
import (
4+
"github.com/spf13/cast"
5+
"os"
46
"strings"
57
"time"
68

@@ -26,6 +28,14 @@ func New() *Config {
2628
return v
2729
}
2830

31+
func GetPort() int {
32+
port := cast.ToInt(os.Getenv("PORT"))
33+
if port == 0 {
34+
port = 3000
35+
}
36+
return port
37+
}
38+
2939
func init() {
3040
cfg := New()
3141
cfg.AutomaticEnv()

backend/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package main
22

33
import (
44
"fmt"
5-
"github.com/diggerhq/digger/backend/segment"
65
"github.com/diggerhq/digger/backend/config"
6+
"github.com/diggerhq/digger/backend/segment"
77
"html/template"
88
"io/fs"
99
"log"
@@ -186,7 +186,9 @@ func main() {
186186
runsApiGroup.POST("/:run_id/approve", controllers.ApproveRun)
187187

188188
fronteggWebhookProcessor.POST("/create-org-from-frontegg", controllers.CreateFronteggOrgFromWebhook)
189-
r.Run(fmt.Sprintf(":%d", cfg.GetInt("port")))
189+
190+
port := config.GetPort()
191+
r.Run(fmt.Sprintf(":%d", port))
190192
}
191193

192194
func initLogging() {

0 commit comments

Comments
 (0)