Exemplo n.º 1
0
func loadConfig() {
	for _, cfgPath := range []string{stateConfig, defaultConfig} {
		if cfgPath == "" {
			continue
		}

		cfgData, err := ioutil.ReadFile(cfgPath)
		if err != nil {
			log.Warnln("Error reading config:", err)
			continue
		}

		var cfg client.Config
		err = json.Unmarshal(cfgData, &cfg)
		if err != nil {
			log.Warnln("Config error:", err)
			continue
		}
		log.Debug("Loaded config from:", cfgPath)

		if err := Registry.UpdateConfig(cfg); err != nil {
			log.Printf("Unable to load config: error: %s", err)
		}
	}
}
Exemplo n.º 2
0
// Start the Service's Accept loop
func (s *Service) runTCP() {
	for {
		conn, err := s.tcpListener.Accept()
		if err != nil {
			if err, ok := err.(net.Error); ok && err.Temporary() {
				log.Warnln("WARN:", err)
				continue
			}
			// we must be getting shut down
			return
		}

		go s.connectTCP(conn)
	}
}