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