From 8decc34ccea1e7ff20658cea5963f34781d5be9a Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 21 Feb 2018 10:35:45 +0100 Subject: [PATCH] Fix: Ensure the tool works on VMs with 1 CPU Signed-off-by: Knut Ahlers --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index d5ad535..16f5555 100644 --- a/main.go +++ b/main.go @@ -69,8 +69,13 @@ func main() { "num_cpu": runtime.NumCPU(), }).Debugf("update-gotools started") + parallelRunners := runtime.NumCPU() - 1 + if parallelRunners < 1 { + parallelRunners = 1 + } + runPreCommands() - runPackageBuilds(runtime.NumCPU()-1, func(pkg pkgCfg) bool { return !pkg.Single }) + runPackageBuilds(parallelRunners, func(pkg pkgCfg) bool { return !pkg.Single }) runPackageBuilds(1, func(pkg pkgCfg) bool { return pkg.Single }) runPostCommands()