MCPcopy
hub / github.com/aceld/zinx / Reload

Method Reload

zconf/zconf.go:142–166  ·  view source on GitHub ↗

Reload 读取用户的配置文件 This method is used to reload the configuration file. It reads the configuration file specified in the command-line arguments, and updates the fields of the "Config" structure accordingly. If the configuration file does not exist, it prints an error message to the log and returns.

()

Source from the content-addressed store, hash-verified

140// and updates the fields of the "Config" structure accordingly.
141// If the configuration file does not exist, it prints an error message to the log and returns.
142func (g *Config) Reload() {
143 confFilePath := GetConfigFilePath()
144 if confFileExists, _ := PathExists(confFilePath); confFileExists != true {
145
146 // The configuration file may not exist,
147 // in which case the default parameters should be used to initialize the logging module configuration.
148 // (配置文件不存在也需要用默认参数初始化日志模块配置)
149 g.InitLogConfig()
150
151 zlog.Ins().ErrorF("Config File %s is not exist!! \n You can set configFile by setting the environment variable %s, like export %s = xxx/xxx/zinx.conf ", confFilePath, EnvConfigFilePathKey, EnvConfigFilePathKey)
152 return
153 }
154
155 data, err := os.ReadFile(confFilePath)
156 if err != nil {
157 panic(err)
158 }
159
160 err = json.Unmarshal(data, g)
161 if err != nil {
162 panic(err)
163 }
164
165 g.InitLogConfig()
166}
167
168// Show Zinx Config Info
169func (g *Config) Show() {

Callers 1

initFunction · 0.80

Calls 5

InitLogConfigMethod · 0.95
InsFunction · 0.92
GetConfigFilePathFunction · 0.85
PathExistsFunction · 0.85
ErrorFMethod · 0.65

Tested by

no test coverage detected