Start worker port from 9000 (#47)

This commit is contained in:
giongto35 2019-06-03 02:41:35 +08:00 committed by GitHub
parent 2a27b7f0e2
commit 12ed615f53

View file

@ -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() {