mirror of
https://github.com/gotoeasy/glogcenter.git
synced 2025-09-15 12:58:34 +08:00
增加CPU配置
This commit is contained in:
parent
b97755c9a6
commit
0e2b1eac4d
@ -7,6 +7,7 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@ -42,6 +43,7 @@ var minioUser string
|
||||
var minioPassword string
|
||||
var minioBucket string
|
||||
var enableUploadMinio bool
|
||||
var goMaxProcess int
|
||||
|
||||
func init() {
|
||||
cmn.SetLogLevel(cmn.GetEnvStr("GLC_LOG_LEVEL", "INFO")) // 默认INFO级别日志
|
||||
@ -87,6 +89,21 @@ func UpdateConfigByEnv() {
|
||||
minioPassword = cmn.GetEnvStr("GLC_MINIO_PASS", "") // MINIO密码,默认“”
|
||||
minioBucket = cmn.GetEnvStr("GLC_MINIO_BUCKET", "") // MINIO桶名,默认“”
|
||||
enableUploadMinio = cmn.GetEnvBool("GLC_ENABLE_UPLOAD_MINIO", false) // 是否开启上传备份至MINIO服务器,默认false
|
||||
goMaxProcess = getGoMaxProcessConf(cmn.GetEnvInt("GLC_GOMAXPROCS", runtime.NumCPU()-1)) // 是否开启上传备份至MINIO服务器,默认false
|
||||
}
|
||||
|
||||
// 取配置: 服务URL,集群配置时自动获取地址可能不对,可通过环境变量“GLC_ENABLE_BACKUP”设定,默认“”
|
||||
func GetGoMaxProcess() int {
|
||||
return goMaxProcess
|
||||
}
|
||||
func getGoMaxProcessConf(n int) int {
|
||||
if n < 1 {
|
||||
n = 1
|
||||
}
|
||||
if n > runtime.NumCPU() {
|
||||
n = runtime.NumCPU()
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
// 取配置: 服务URL,集群配置时自动获取地址可能不对,可通过环境变量“GLC_ENABLE_BACKUP”设定,默认“”
|
||||
|
||||
Loading…
Reference in New Issue
Block a user