Accept port as a command line param

This commit is contained in:
Alex Myasoedov 2017-03-01 19:08:04 -05:00
parent a535f8fecd
commit 9c26469d81

11
main.go
View file

@ -163,6 +163,15 @@ func NewApp() *gin.Engine {
func main() {
r := NewApp()
port := "8080"
if len(os.Args) > 1 {
port = os.Args[1]
} else {
envPort := os.Getenv("PORT")
if len(envPort) > 0 {
port = envPort
}
}
log.Info("Started http://0.0.0.0:8080")
r.Run(":8080")
r.Run(fmt.Sprintf(":%s", port))
}