refactor(client): if subdir is empty from cfg file, use cfg from option.

Signed-off-by: Victor1319 <zengxuewei@oppo.com>
This commit is contained in:
Victor1319 2024-11-04 15:28:14 +08:00 committed by AmazingChi
parent b57d898709
commit 1e8ffbeb73
2 changed files with 8 additions and 2 deletions

View File

@ -541,6 +541,11 @@ func main() {
}
}
if cfg.GetString(exporter.ConfigKeySubDir) == "" {
cfg.SetString(exporter.ConfigKeySubDir, opt.SubDir)
syslog.Printf("config subdir empty, use cfg from mnt, subdir %s", opt.SubDir)
}
exporter.Init(ModuleName, cfg)
exporter.RegistConsul(super.ClusterName(), ModuleName, cfg)
metric := exporter.NewVersionMetrics(ModuleName)

View File

@ -44,6 +44,7 @@ const (
ConfigKeyEnablePid = "enablePid" // enable report partition id
ConfigKeyPushAddr = "pushAddr" // enable push data to gateway
ChSize = 1024 * 10 // collect chan size
ConfigKeySubDir = "subdir"
// monitor label name
Vol = "vol"
@ -161,12 +162,12 @@ func RegistConsul(cluster string, role string, cfg *config.Config) {
return
}
rawmnt := cfg.GetString("subdir")
rawmnt := cfg.GetString(ConfigKeySubDir)
if rawmnt == "" {
rawmnt = "/"
}
mountPoint, _ := filepath.Abs(rawmnt)
log.LogInfof("RegistConsul:%v", enablePush)
log.LogWarnf("RegistConsul:%v, subdir %s", enablePush, mountPoint)
if enablePush {
log.LogWarnf("[RegisterConsul] use auto push data strategy, not register consul")
autoPush(pushAddr, role, cluster, host, mountPoint)