Skip to content

Commit 1a349a4

Browse files
authored
fix: fix the zk don't start problem (#328)
* feat: add some api about admin * feat: add some api about admin * fix: del the unuse method * fix: Optimized code * fix: fix the userID * fix: del the config code getting from zk * fix: fix the initRedis * fix: add the get Evn method in Config * fix: fix the config.yaml.template * fix: fix the env config * feat: add some conponent env * fix: fix the openIMURL * fix: find the zk don't connect error * fix: find the zk error * fix: test the jz error * fix: delt the log * fix: fix the component error * fix: fix the error of get env location * fix: fix the error * fix: fix the zk start error * fix: fix the Config * fix: testing * fix: fix the config.Env error * fix: fix the componentCheck * fix: fix the config * fix: find the error * fix: del the flag * fix: fix the error
1 parent 1d61e67 commit 1a349a4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

pkg/common/config/parse.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,16 @@ func InitConfig(configFile string) error {
7979
if err := yaml.NewDecoder(bytes.NewReader(data)).Decode(&Config); err != nil {
8080
return fmt.Errorf("parse loacl openIMConfig file error: %w", err)
8181
}
82+
if err != nil {
83+
return utils.Wrap(err, configFile)
84+
}
8285

8386
if err := configGetEnv(); err != nil {
8487
return fmt.Errorf("get env error:%w", err)
8588
}
8689

8790
configData, err := yaml.Marshal(&Config)
8891
fmt.Printf("debug: %s\nconfig:\n%s\n", time.Now(), string(configData))
89-
if err != nil {
90-
return utils.Wrap(err, configFile)
91-
}
92-
fmt.Printf("%s\nconfig:\n%s\n", time.Now(), string(configData))
9392

9493
return nil
9594
}
@@ -226,7 +225,6 @@ func configGetEnv() error {
226225
Config.Zookeeper.Schema = getEnv("ZOOKEEPER_SCHEMA", Config.Zookeeper.Schema)
227226
Config.Zookeeper.Username = getEnv("ZOOKEEPER_USERNAME", Config.Zookeeper.Username)
228227
Config.Zookeeper.Password = getEnv("ZOOKEEPER_PASSWORD", Config.Zookeeper.Password)
229-
Config.Zookeeper.ZkAddr = getArrEnv("ZOOKEEPER_ADDRESS", "ZOOKEEPER_PORT", Config.Zookeeper.ZkAddr)
230228

231229
Config.ChatApi.ListenIP = getEnv("CHAT_API_LISTEN_IP", Config.ChatApi.ListenIP)
232230
Config.AdminApi.ListenIP = getEnv("ADMIN_API_LISTEN_IP", Config.AdminApi.ListenIP)
@@ -253,18 +251,21 @@ func configGetEnv() error {
253251
if err != nil {
254252
return err
255253
}
256-
254+
getArrEnv("ZOOKEEPER_ADDRESS", "ZOOKEEPER_PORT", Config.Zookeeper.ZkAddr)
257255
return nil
258256
}
259257

260-
func getArrEnv(key1, key2 string, fallback []string) []string {
258+
func getArrEnv(key1, key2 string, fallback []string) {
261259
str1 := getEnv(key1, "")
262260
str2 := getEnv(key2, "")
263261
str := fmt.Sprintf("%s:%s", str1, str2)
262+
arr := make([]string, 1)
264263
if len(str) <= 1 {
265-
return fallback
264+
return
266265
}
267-
return []string{str}
266+
arr[0] = str
267+
fmt.Println("zookeeper Envirement valiable", "str", str)
268+
Config.Zookeeper.ZkAddr = arr
268269
}
269270

270271
func getArrPointEnv(key1, key2 string, fallback *[]string) *[]string {

0 commit comments

Comments
 (0)