コード例 #1
0
ファイル: embed_test.go プロジェクト: mgurevin/etcd
func setupEmbedCfg(cfg *embed.Config, curls []url.URL, purls []url.URL) {
	cfg.ClusterState = "new"
	cfg.LCUrls, cfg.ACUrls = curls, curls
	cfg.LPUrls, cfg.APUrls = purls, purls
	cfg.InitialCluster = ""
	for i := range purls {
		cfg.InitialCluster += ",default=" + purls[i].String()
	}
	cfg.InitialCluster = cfg.InitialCluster[1:]
}
コード例 #2
0
ファイル: etcd.go プロジェクト: hongchaodeng/etcd
// startEtcd runs StartEtcd in addition to hooks needed for standalone etcd.
func startEtcd(cfg *embed.Config) (<-chan struct{}, <-chan error, error) {
	defaultHost, dhErr := cfg.IsDefaultHost()
	if defaultHost != "" {
		if dhErr == nil {
			plog.Infof("advertising using detected default host %q", defaultHost)
		} else {
			plog.Noticef("failed to detect default host, advertise falling back to %q (%v)", defaultHost, dhErr)
		}
	}

	e, err := embed.StartEtcd(cfg)
	if err != nil {
		return nil, nil, err
	}
	osutil.RegisterInterruptHandler(e.Server.Stop)
	<-e.Server.ReadyNotify() // wait for e.Server to join the cluster
	return e.Server.StopNotify(), e.Err(), nil
}