Created
October 15, 2017 23:16
-
-
Save starius/4a204ae2069c235eaaeceb45e99578a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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