cmd/cli: fix wrong config file reading during self-check

At the time self-check process running, we have already known the exact
config file being used by ctrld service. Thus, we should just re-read
this config file directly instead of guessing the config file.
This commit is contained in:
Cuong Manh Le
2024-07-29 15:43:29 +07:00
committed by Cuong Manh Le
parent ec684348ed
commit bc7b1cc6d8

View File

@@ -1654,9 +1654,10 @@ func selfCheckStatus(s service.Service, homedir, sockDir string) (bool, service.
}
v = viper.NewWithOptions(viper.KeyDelimiter("::"))
ctrld.SetConfigNameWithPath(v, "ctrld", homedir)
if configPath != "" {
v.SetConfigFile(configPath)
} else {
v.SetConfigFile(defaultConfigFile)
}
if err := v.ReadInConfig(); err != nil {
mainLog.Load().Error().Err(err).Msgf("failed to re-read configuration file: %s", v.ConfigFileUsed())