Пример #1
0
func main() {
	fs.Usage = flags.UsageWithIgnoredFlagsFunc(fs, ignored)
	err := fs.Parse(os.Args[1:])
	switch err {
	case nil:
	case flag.ErrHelp:
		os.Exit(0)
	default:
		os.Exit(2)
	}

	if *printVersion {
		fmt.Println("etcd version", version.Version)
		os.Exit(0)
	}

	flags.SetFlagsFromEnv(fs)

	if string(*proxyFlag) == flags.ProxyValueOff {
		startEtcd()
	} else {
		startProxy()
	}

	// Block indefinitely
	<-make(chan struct{})
}
Пример #2
0
func Main() {
	fs.Usage = flags.UsageWithIgnoredFlagsFunc(fs, ignored)
	perr := fs.Parse(os.Args[1:])
	switch perr {
	case nil:
	case flag.ErrHelp:
		os.Exit(0)
	default:
		os.Exit(2)
	}

	if *printVersion {
		fmt.Println("etcd version", version.Version)
		os.Exit(0)
	}

	err := flags.SetFlagsFromEnv(fs)
	if err != nil {
		log.Fatalf("etcd: %v", err)
	}

	shouldProxy := proxyFlag.String() != proxyFlagOff
	var stopped <-chan struct{}
	if !shouldProxy {
		stopped, err = startEtcd()
		if err == discovery.ErrFullCluster && fallbackFlag.String() == fallbackFlagProxy {
			log.Printf("etcd: discovery cluster full, falling back to %s", fallbackFlagProxy)
			shouldProxy = true
		}
	}
	if shouldProxy {
		err = startProxy()
	}
	if err != nil {
		log.Fatalf("etcd: %v", err)
	}
	<-stopped
}