mirror of
https://github.com/usual2970/certimate.git
synced 2025-07-25 20:28:35 +00:00
feat: set the default max workers to the number of available CPU cores
This commit is contained in:
@@ -15,12 +15,17 @@ import (
|
||||
sliceutil "github.com/usual2970/certimate/internal/pkg/utils/slice"
|
||||
)
|
||||
|
||||
var maxWorkers = runtime.NumCPU()
|
||||
var maxWorkers = 1
|
||||
|
||||
func init() {
|
||||
envMaxWorkers := os.Getenv("CERTIMATE_WORKFLOW_MAX_WORKERS")
|
||||
if n, err := strconv.Atoi(envMaxWorkers); err != nil && n > 0 {
|
||||
maxWorkers = n
|
||||
} else {
|
||||
maxWorkers = runtime.GOMAXPROCS(0)
|
||||
if maxWorkers == 0 {
|
||||
maxWorkers = max(1, runtime.NumCPU())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user