Exemple #1
0
func heartbeat(s *service.Service) {
	go func() {
		for _ = range time.Tick(time.Duration(environment.Frequency()-1) * time.Second) {
			setServer(s)
		}
	}()
}
Exemple #2
0
func setServer(s *service.Service) {
	serviceurl, err := json.Marshal(environment.URL())
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
	}
	client := etcd.NewClient(Machines())
	_, err = client.Set(serverPath(s), string(serviceurl), environment.Frequency())
	if err != nil {
		fmt.Fprint(os.Stderr, err)
	}
}
Exemple #3
0
func refreshEtcdMachines() {
	go func() {
		for _ = range time.Tick(time.Duration(environment.Frequency()) * time.Second) {
			machines, err := environment.GetEnvValue("ETCD_MACHINES")
			if err != nil || machines == "" {
				if err != nil {
					fmt.Fprint(os.Stderr, err)
				}
				if machines == "" {
					fmt.Fprintf(os.Stderr, "ETCD_MACHINES not set.")
				}
			} else {
				etcdmachines = machines
			}
		}
	}()
}