Worker listen to random port so we can run multiple worker

This commit is contained in:
giongto35 2019-05-21 23:54:31 +08:00
parent 4cf3d4c9c5
commit a461415038
2 changed files with 9 additions and 1 deletions

View file

@ -7,6 +7,7 @@ import (
"net/http"
_ "net/http/pprof"
"runtime"
"strconv"
"strings"
"time"
@ -63,7 +64,9 @@ func initializeWorker() {
}()
go worker.Run()
http.ListenAndServe(":8001", nil)
port := rand.Int()%100 + 8000
log.Println("Listening at port: localhost:", port)
http.ListenAndServe(":"+strconv.Itoa(port), nil)
}
func monitor() {

View file

@ -165,6 +165,11 @@ func (v *VpxEncoder) startLooping() {
log.Println("Encoding time: ", time.Now().Sub(beginEncoding))
}
}
if v.Done == true {
// The first time we see IsRunning set to false, we release and return
v.Release()
return
}
}
// Release release memory and stop loop