Skip to content

Instantly share code, notes, and snippets.

@starius
Created October 15, 2017 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save starius/4a204ae2069c235eaaeceb45e99578a8 to your computer and use it in GitHub Desktop.
Save starius/4a204ae2069c235eaaeceb45e99578a8 to your computer and use it in GitHub Desktop.
package main
import (
"github.com/coreos/etcd/embed"
"log"
"time"
)
func main() {
cfg := embed.NewConfig()
cfg.Dir = "default.etcd"
e, err := embed.StartEtcd(cfg)
if err != nil {
log.Fatal(err)
}
defer e.Close()
select {
case <-e.Server.ReadyNotify():
log.Printf("Server is ready!")
case <-time.After(60 * time.Second):
e.Server.Stop() // trigger a shutdown
log.Printf("Server took too long to start!")
}
log.Fatal(<-e.Err())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment