Skip to content

Commit

Permalink
feat: Load port from env var
Browse files Browse the repository at this point in the history
Load port to run the application on from environment variable with 5000 as
the fallback.
  • Loading branch information
sudo-suhas committed Dec 6, 2017
1 parent 25bad31 commit da83c8a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions application.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package main

import (
"log"
"os"

"github.com/gin-gonic/gin"
)

Expand Down Expand Up @@ -53,6 +56,11 @@ func main() {
}
})

// Listen and Server in 0.0.0.0:8080
r.Run(":8080")
// Listen and Server in 0.0.0.0:$PORT
port := os.Getenv("PORT")
if port == "" {
port = "5000"
}
err := r.Run(":" + port)
log.Panic(err)
}

0 comments on commit da83c8a

Please sign in to comment.