diff options
Diffstat (limited to 'modules/setting/queue.go')
-rw-r--r-- | modules/setting/queue.go | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/modules/setting/queue.go b/modules/setting/queue.go index 8673537b52..fc15bd07ed 100644 --- a/modules/setting/queue.go +++ b/modules/setting/queue.go @@ -5,6 +5,7 @@ package setting import ( "path/filepath" + "runtime" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" @@ -25,18 +26,24 @@ type QueueSettings struct { MaxWorkers int } -var queueSettingsDefault = QueueSettings{ - Type: "level", // dummy, channel, level, redis - Datadir: "queues/common", // relative to AppDataPath - Length: 100, // queue length before a channel queue will block - - QueueName: "_queue", - SetName: "_unique", - BatchLength: 20, - MaxWorkers: 10, -} - func GetQueueSettings(rootCfg ConfigProvider, name string) (QueueSettings, error) { + queueSettingsDefault := QueueSettings{ + Type: "level", // dummy, channel, level, redis + Datadir: "queues/common", // relative to AppDataPath + Length: 100, // queue length before a channel queue will block + + QueueName: "_queue", + SetName: "_unique", + BatchLength: 20, + MaxWorkers: runtime.NumCPU() / 2, + } + if queueSettingsDefault.MaxWorkers < 1 { + queueSettingsDefault.MaxWorkers = 1 + } + if queueSettingsDefault.MaxWorkers > 10 { + queueSettingsDefault.MaxWorkers = 10 + } + // deep copy default settings cfg := QueueSettings{} if cfgBs, err := json.Marshal(queueSettingsDefault); err != nil { |