Skip to content

Commit

Permalink
fix: fix the zk don't start problem (#328)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
luhaoling authored Dec 18, 2023
1 parent 1d61e67 commit 1a349a4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pkg/common/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,16 @@ func InitConfig(configFile string) error {
if err := yaml.NewDecoder(bytes.NewReader(data)).Decode(&Config); err != nil {
return fmt.Errorf("parse loacl openIMConfig file error: %w", err)
}
if err != nil {
return utils.Wrap(err, configFile)
}

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

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

return nil
}
Expand Down Expand Up @@ -226,7 +225,6 @@ func configGetEnv() error {
Config.Zookeeper.Schema = getEnv("ZOOKEEPER_SCHEMA", Config.Zookeeper.Schema)
Config.Zookeeper.Username = getEnv("ZOOKEEPER_USERNAME", Config.Zookeeper.Username)
Config.Zookeeper.Password = getEnv("ZOOKEEPER_PASSWORD", Config.Zookeeper.Password)
Config.Zookeeper.ZkAddr = getArrEnv("ZOOKEEPER_ADDRESS", "ZOOKEEPER_PORT", Config.Zookeeper.ZkAddr)

Config.ChatApi.ListenIP = getEnv("CHAT_API_LISTEN_IP", Config.ChatApi.ListenIP)
Config.AdminApi.ListenIP = getEnv("ADMIN_API_LISTEN_IP", Config.AdminApi.ListenIP)
Expand All @@ -253,18 +251,21 @@ func configGetEnv() error {
if err != nil {
return err
}

getArrEnv("ZOOKEEPER_ADDRESS", "ZOOKEEPER_PORT", Config.Zookeeper.ZkAddr)
return nil
}

func getArrEnv(key1, key2 string, fallback []string) []string {
func getArrEnv(key1, key2 string, fallback []string) {
str1 := getEnv(key1, "")
str2 := getEnv(key2, "")
str := fmt.Sprintf("%s:%s", str1, str2)
arr := make([]string, 1)
if len(str) <= 1 {
return fallback
return
}
return []string{str}
arr[0] = str
fmt.Println("zookeeper Envirement valiable", "str", str)
Config.Zookeeper.ZkAddr = arr
}

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

0 comments on commit 1a349a4

Please sign in to comment.