Respect PORT environment variable

this makes it easier to run on PaaS as heroku
This commit is contained in:
bumi 2020-10-25 23:44:40 +01:00
parent 89ecea4d4a
commit f79fb1747f
1 changed files with 5 additions and 1 deletions

View File

@ -141,7 +141,11 @@ func main() {
return c.JSON(http.StatusOK, "pong")
})
e.Logger.Fatal(e.Start(":" + cfg.String("port")))
port := cfg.String("port")
if os.Getenv("PORT") != "" {
port = os.Getenv("PORT")
}
e.Logger.Fatal(e.Start(":" + port))
}
func LoadConfig() *koanf.Koanf {