Example #1
0
func getCfg(config string) {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
		}
	}()
	var errcfg error
	for {
		data, err := ioutil.ReadFile(config)
		if err != nil {
			panic("config error")
		}
		sha1 := b(string(data))
		if sha1 == cfgStatus {
			continue
			dun := 10 * time.Second
			time.Sleep(dun)
		}
		cfgStatus = sha1

		inicfg, errcfg = ini.Load(config)
		if errcfg != nil {
			panic("config error")
		}
		//		fmt.Println(inicfg)
		mysql, err := inicfg.GetSection("mysql")
		if err != nil {
			panic("mysql config error")
		}
		key := mysql.Key("password")
		fmt.Println(key.String())
	}

}
Example #2
0
func loadConfig() error {
	midolmanConfigPath := flag.String("config", "/etc/midolman/midolman.conf",
		"The location of the Midolamn config file")
	hostConfigPath := flag.String("host-config", "/etc/midonet_host_id.properties",
		"The location of the host UUID config file")
	flag.Parse()

	cfg, err := ini.Load(*midolmanConfigPath, *hostConfigPath)
	if err != nil {
		return err
	}
	zkSection, err := cfg.GetSection("zookeeper")
	if err != nil {
		return err
	}
	*rootPath = zkSection.Key("root_key").String()
	*nsdbAddresses = zkSection.Key("zookeeper_hosts").String()
	*hostUuid = cfg.Section("").Key("host_uuid").String()

	return nil
}