Skip to content

Commit

Permalink
Set default PORT if not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-nguyen committed Dec 24, 2018
1 parent 750def3 commit c4e7011
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ func getLobby(w http.ResponseWriter, r *http.Request) {
func main() {
rand.Seed(time.Now().UTC().UnixNano())

PORT := os.Getenv("PORT")
if PORT == "" {
PORT = "9090"
}

arena.MessageChannel = make(chan models.Message)
game := game.CreateGame()

// database.ConnectDB("service-account.json")
// if database.DBC == nil {
// log.Println("DBClient not initialized correctly")
// }

http.Handle("/", http.FileServer(http.Dir("./build")))
http.HandleFunc("/start", getLobby)
http.Handle("/connect", game)
game.StartGame()

log.Println("Starting server on localhost:" + os.Getenv("PORT"))
log.Println(http.ListenAndServe(":"+os.Getenv("PORT"), nil))
log.Println("Starting server on localhost:" + PORT)
log.Println(http.ListenAndServe(":"+PORT, nil))
}

0 comments on commit c4e7011

Please sign in to comment.