2020-05-05 22:02:16 +00:00
|
|
|
// +build !no_embedded_executor
|
|
|
|
|
|
|
|
package executor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"go.etcd.io/etcd/embed"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (e Embedded) CurrentETCDOptions() (InitialOptions, error) {
|
|
|
|
return InitialOptions{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e Embedded) ETCD(args ETCDConfig) error {
|
|
|
|
configFile, err := args.ToConfigFile()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
cfg, err := embed.ConfigFromFile(configFile)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
etcd, err := embed.StartEtcd(cfg)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
go func() {
|
2020-10-27 18:06:26 +00:00
|
|
|
select {
|
|
|
|
case <-etcd.Server.StopNotify():
|
|
|
|
logrus.Fatalf("etcd stopped - if this node was removed from the cluster, you must backup and delete %s before rejoining", args.DataDir)
|
|
|
|
case err := <-etcd.Err():
|
|
|
|
logrus.Fatalf("etcd exited: %v", err)
|
|
|
|
}
|
2020-05-05 22:02:16 +00:00
|
|
|
}()
|
|
|
|
return nil
|
|
|
|
}
|