增加CPU配置

This commit is contained in:
gotoeasy 2022-11-29 15:44:41 +08:00
parent ada476b8c9
commit cf3d4add7e
2 changed files with 35 additions and 37 deletions

View File

@ -89,19 +89,17 @@ 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
goMaxProcess = getGoMaxProcessConf(cmn.GetEnvInt("GLC_GOMAXPROCS", -1)) // 使用的最大CPU数量默认是最大CPU数量设定值不在实际数量范围是按最大看待
}
// 取配置: 服务URL集群配置时自动获取地址可能不对可通过环境变量“GLC_ENABLE_BACKUP”设定默认“”
// 取配置: 使用的最大CPU数量可通过环境变量“GLC_GOMAXPROCS”设定默认最大CPU数量
func GetGoMaxProcess() int {
return goMaxProcess
}
func getGoMaxProcessConf(n int) int {
if n < 1 {
n = 1
}
if n > runtime.NumCPU() {
n = runtime.NumCPU()
max := runtime.NumCPU()
if n < 1 || n > max {
n = max
}
return n
}

View File

@ -1,3 +1,3 @@
package onstart
const VERSION = "glogcenter 0.8.2"
const VERSION = "glogcenter 0.8.3"