Skip to content

Commit

Permalink
Enable port configuration with environment variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
hscells committed Oct 12, 2018
1 parent 7a97468 commit 5deae71
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/bigbro/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/hscells/bigbro"
"log"
"os"
)

type server struct {
Expand Down Expand Up @@ -78,6 +79,11 @@ func main() {
c.Next()
})

port := os.Getenv("BIGBRO_PORT")
if len(port) == 0 {
port = "1984"
}

g.GET("/event", s.handleEvent)
if goterm.Width() > 91 {
fmt.Print(`
Expand All @@ -90,16 +96,16 @@ func main() {
...is always watching
Harry Scells 2018
version 09.Aug.2018
version 13.Oct.2018
`)
} else {
fmt.Print(`Big Brother
...is always watching
Harry Scells 2018
version 18.Sep.2018
version 13.Oct.2018
`)
}
g.Run("0.0.0.0:1984")
g.Run(fmt.Sprintf("0.0.0.0:%s", port))
}

0 comments on commit 5deae71

Please sign in to comment.