feat: set runtime.NumCPU() as default worker num value (#174)
This commit is contained in:
parent
aff833cd0c
commit
962c033246
|
@ -57,8 +57,10 @@ See the [YAML config example](config/config.yml):
|
|||
```yaml
|
||||
core:
|
||||
port: "8088"
|
||||
worker_num: 8
|
||||
queue_num: 8192
|
||||
# default worker number is runtime.NumCPU()
|
||||
worker_num: 0
|
||||
# default queue number is 8192
|
||||
queue_num: 0
|
||||
max_notification: 100
|
||||
mode: "release"
|
||||
ssl: false
|
||||
|
|
|
@ -182,5 +182,13 @@ func LoadConfYaml(confPath string) (ConfYaml, error) {
|
|||
return config, err
|
||||
}
|
||||
|
||||
if config.Core.WorkerNum == int64(0) {
|
||||
config.Core.WorkerNum = int64(runtime.NumCPU())
|
||||
}
|
||||
|
||||
if config.Core.QueueNum == int64(0) {
|
||||
config.Core.QueueNum = int64(8192)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
core:
|
||||
port: "8088"
|
||||
worker_num: 8
|
||||
queue_num: 8192
|
||||
# default worker number is runtime.NumCPU()
|
||||
worker_num: 0
|
||||
# default queue number is 8192
|
||||
queue_num: 0
|
||||
max_notification: 100
|
||||
mode: "release"
|
||||
ssl: false
|
||||
|
|
|
@ -112,7 +112,7 @@ func (suite *ConfigTestSuite) TestValidateConfDefault() {
|
|||
func (suite *ConfigTestSuite) TestValidateConf() {
|
||||
// Core
|
||||
assert.Equal(suite.T(), "8088", suite.ConfGorush.Core.Port)
|
||||
assert.Equal(suite.T(), int64(8), suite.ConfGorush.Core.WorkerNum)
|
||||
assert.Equal(suite.T(), int64(runtime.NumCPU()), suite.ConfGorush.Core.WorkerNum)
|
||||
assert.Equal(suite.T(), int64(8192), suite.ConfGorush.Core.QueueNum)
|
||||
assert.Equal(suite.T(), "release", suite.ConfGorush.Core.Mode)
|
||||
assert.Equal(suite.T(), false, suite.ConfGorush.Core.SSL)
|
||||
|
|
Loading…
Reference in New Issue