Ejemplo n.º 1
0
func main() {
	endpoint := getopt("DOCKER_HOST", "unix:///var/run/docker.sock")
	etcdHost := getopt("ETCD_HOST", "127.0.0.1")

	client, err := docker.NewClient(endpoint)
	if err != nil {
		log.Fatal(err)
	}
	etcdClient := etcd.NewClient([]string{"http://" + etcdHost + ":4001"})

	server := &server.Server{client, etcdClient}

	go server.Listen(etcdTTL)

	for {
		go server.Poll(etcdTTL)
		time.Sleep(timeout)
	}
}
Ejemplo n.º 2
0
func main() {
	flag.Parse()

	dockerClient, err := docker.NewClient(*dockerHost)
	if err != nil {
		log.Fatal(err)
	}
	etcdClient := etcd.NewClient([]string{"http://" + *etcdHost + ":" + *etcdPort})

	server := server.New(dockerClient, etcdClient, *host, *logLevel)

	go server.Listen(*etcdTTL)

	go func() {
		log.Println(http.ListenAndServe("localhost:6060", nil))
	}()

	for {
		go server.Poll(*etcdTTL)
		time.Sleep(*refreshDuration)
	}
}