From 31425ab514678f79659d4782c1b78719156536ae Mon Sep 17 00:00:00 2001 From: matu6968 Date: Thu, 21 Nov 2024 02:35:34 +0100 Subject: [PATCH] enable prod mode on gin-sonic and display used port when prod mode is on --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 87cfa45..86e0293 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,8 @@ type AppMetadata struct { } func init() { + // set production mode on gin, if you are facing issues then remove this line and see what is going on in debug mode + gin.SetMode(gin.ReleaseMode) // Load .env file if err := godotenv.Load(); err != nil { // Create .env if it doesn't exist @@ -42,6 +44,11 @@ func init() { ioutil.WriteFile(".env", []byte(envContent), 0644) godotenv.Load() } + websrvport := os.Getenv("PORT") + if websrvport == "" { + websrvport = "8080" + } + fmt.Printf("Starting web server on port %s\n", websrvport) } func authMiddleware() gin.HandlerFunc {