fix: asynq concurrency set to cpu num

This commit is contained in:
Paul Pan 2024-01-07 00:39:33 +08:00
parent 802ce46f7f
commit 55f76636fd
Signed by: Paul
GPG Key ID: D639BDF5BA578AF4

View File

@ -6,10 +6,12 @@ import (
"git.0x7f.app/WOJ/woj-server/internal/misc/config"
"git.0x7f.app/WOJ/woj-server/internal/misc/log"
"git.0x7f.app/WOJ/woj-server/internal/model"
"git.0x7f.app/WOJ/woj-server/pkg/utils"
"git.0x7f.app/WOJ/woj-server/pkg/zapasynq"
"github.com/hibiken/asynq"
"github.com/samber/do"
"go.uber.org/zap"
"runtime"
)
func RunRunner(i *do.Injector) error {
@ -32,7 +34,7 @@ func RunRunner(i *do.Injector) error {
DB: conf.Redis.QueueDb,
},
asynq.Config{
Concurrency: 1, // there's a worker pool in runner service
Concurrency: utils.If(runtime.NumCPU() > 1, runtime.NumCPU()-1, 1),
Logger: zapasynq.New(rlog),
Queues: map[string]int{model.QueueRunner: 1},
},