forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
etcd.go
36 lines (31 loc) · 816 Bytes
/
etcd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package etcd
import (
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
etcdconfig "github.com/coreos/etcd/config"
"github.com/coreos/etcd/etcd"
"github.com/golang/glog"
)
// Config is an object that can run an etcd server
type Config struct {
BindAddr string
PeerBindAddr string
MasterAddr string
EtcdDir string
}
// Run starts an etcd server and runs it forever
func (c *Config) Run() {
config := etcdconfig.New()
config.Addr = c.MasterAddr
config.BindAddr = c.BindAddr
config.Peer.BindAddr = c.PeerBindAddr
config.DataDir = c.EtcdDir
config.Name = "openshift.local"
server := etcd.New(config)
go util.Forever(func() {
glog.Infof("Started etcd at %s", config.Addr)
server.Run()
glog.Fatalf("etcd died, exiting.")
}, 500*time.Millisecond)
<-server.ReadyNotify()
}