예제 #1
0
파일: monitor.go 프로젝트: lucmichalski/fae
func watchFaes() {
	ch := make(chan []string, 10)
	go etclib.WatchService(etclib.SERVICE_FAE, ch)

	for {
		select {
		case <-ch:
			endpoints, err := etclib.ServiceEndpoints(etclib.SERVICE_FAE)
			if err == nil {
				log.Trace("fae endpoints updated: %+v", endpoints)

				dumpFaeConfigPhp(endpoints)
			} else {
				log.Error("fae: %s", err)
			}
		}
	}

	log.Warn("fae watcher died")
}
예제 #2
0
파일: proxy.go 프로젝트: lucmichalski/fae
func (this *Proxy) StartMonitorCluster() {
	if !this.Enabled() {
		log.Warn("servant proxy disabled by proxy config section")
		return
	}

	peersChan := make(chan []string, 10)
	go etclib.WatchService(etclib.SERVICE_FAE, peersChan)

	for {
		select {
		case <-peersChan:
			peers, err := etclib.ServiceEndpoints(etclib.SERVICE_FAE)
			if err == nil {
				if !this.clusterTopologyReady {
					this.clusterTopologyReady = true
					close(this.clusterTopologyChan)
				}

				if len(peers) == 0 {
					// TODO panic?
					log.Warn("Empty cluster fae peers")
				} else {
					// no lock, because running within 1 goroutine
					this.selector.SetPeersAddr(peers...)
					this.refreshPeers(peers)

					log.Info("Cluster latest fae nodes: %+v", peers)
				}
			} else {
				log.Error("Cluster peers: %s", err)
			}
		}
	}

	// should never get here
	log.Warn("Cluster peers monitor died")
}