Exemple #1
0
func (opts *versionOpts) run(_ *cobra.Command, args []string) error {
	if len(args) > 0 {
		return fmt.Errorf("Unexpected arguments: %s", args)
	}
	fmt.Fprintf(opts.getStdout(), "%s version %s\n", path.Base(os.Args[0]), version.Version())
	return nil
}
Exemple #2
0
func main() {
	log.Infof("flux agent version %s", version.Version())
	var (
		hostIP string
	)
	flag.StringVar(&hostIP, "host-ip", "", "IP address for instances with mapped ports")
	flag.Parse()

	dc, err := setupDockerClient()
	if err != nil {
		log.Fatalf("Error connecting to docker: %s", err)
	}

	hostIpFrom := "argument"

	if hostIP == "" {
		hostIP = os.Getenv("HOST_IP")
		hostIpFrom = `$HOST_IP in environment`
	}

	if hostIP == "" {
		hostname, err := os.Hostname()
		if err != nil {
			log.Fatalf("Unable to determine host IP via hostname: %s", err)
		}
		ip, err := net.ResolveIPAddr("ip", hostname)
		if err != nil {
			log.Fatalf("Unable to determine host IP via hostname: %s", err)
		}
		hostIP = ip.String()
		hostIpFrom = fmt.Sprintf(`resolving hostname '%s'`, hostname)
	}

	log.Infof(`Using host IP address '%s' from %s`, hostIP, hostIpFrom)

	store, err := etcdstore.NewFromEnv()
	if err != nil {
		log.Fatal(err)
	}

	listener := agent.NewListener(agent.Config{
		HostIP:    hostIP,
		Store:     store,
		Inspector: dc,
	})

	events := make(chan *docker.APIEvents)
	if err := dc.AddEventListener(events); err != nil {
		log.Fatalf("Unable to add listener to Docker API: %s", err)
	}

	if err := listener.ReadExistingContainers(); err != nil {
		log.Fatalf("Error reading existing containers: %s", err)
	}
	if err := listener.ReadInServices(); err != nil {
		log.Fatalf("Error reading configuration: %s", err)
	}
	listener.Run(events)
}
Exemple #3
0
func main() {
	log.Infof("flux balancer version %s", version.Version())
	daemon.Main(func(args []string, errs daemon.ErrorSink) daemon.Daemon {
		b, err := balancer.NewBalancer(args, errs, iptables)
		if err != nil {
			errs.Post(err)
			return nil
		}

		b.Start()
		return b
	})
}
Exemple #4
0
func main() {
	log.Printf("flux web version %s\n", version.Version())
	prom := os.Getenv("PROMETHEUS_ADDRESS")
	if prom == "" {
		prom = "http://localhost:9090"
	}

	store, err := etcdstore.NewFromEnv()
	if err != nil {
		log.Fatal(err)
	}

	if err := store.Ping(); err != nil {
		log.Fatal(err)
	}

	log.Printf("Connected to backend\n")
	api := &api{store, prom}

	http.ListenAndServe("0.0.0.0:7070", api.router())
}
Exemple #5
0
func main() {
	log.Infof("flux balagent version %s", version.Version())
	daemon.Main(func(args []string, errs daemon.ErrorSink) daemon.Daemon {
		return balagent.StartBalancerAgent(args, errs)
	})
}