add build queue shuffling

This commit is contained in:
2021-06-14 15:00:36 +02:00
parent be890c82eb
commit 04d2f60e26

View File

@@ -11,6 +11,7 @@ import (
"github.com/yargevad/filepathx"
"gopkg.in/yaml.v2"
"io"
"math/rand"
"os"
"os/exec"
"os/signal"
@@ -578,6 +579,10 @@ func (b *BuildManager) syncWorker() {
pkgBuilds, err := filepathx.Glob(filepath.Join(conf.Basedir.Upstream, "/**/PKGBUILD"))
check(err)
// Shuffle pkgbuilds to spread out long-running builds, otherwise pkgBuilds is alphabetically-sorted
rand.Seed(time.Now().UnixNano())
rand.Shuffle(len(pkgBuilds), func(i, j int) { pkgBuilds[i], pkgBuilds[j] = pkgBuilds[j], pkgBuilds[i] })
for _, pkgbuild := range pkgBuilds {
if b.exit {
return