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.
()
| 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. |
| 142 | func (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 |
| 169 | func (g *Config) Show() { |
no test coverage detected