mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 10:35:44 +00:00
Start worker port from 9000 (#47)
This commit is contained in:
parent
2a27b7f0e2
commit
12ed615f53
1 changed files with 13 additions and 3 deletions
16
cmd/main.go
16
cmd/main.go
|
|
@ -54,9 +54,19 @@ func initializeWorker() {
|
|||
}()
|
||||
|
||||
go worker.Run()
|
||||
port := rand.Int()%100 + 8000
|
||||
log.Println("Listening at port: localhost:", port)
|
||||
http.ListenAndServe(":"+strconv.Itoa(port), nil)
|
||||
port := 9000
|
||||
// It's recommend to run one worker on one instance. This logic is to make sure more than 1 workers still work
|
||||
for {
|
||||
log.Println("Listening at port: localhost:", port)
|
||||
err := http.ListenAndServe(":"+strconv.Itoa(port), nil)
|
||||
if err != nil {
|
||||
port++
|
||||
}
|
||||
if port == 9100 {
|
||||
// Cannot find port
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func monitor() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue