Exemple #1
0
func LeaveDatastore() error {
	if err := ecc.Leave(); err != nil {
		log.Error(err)
		return err
	}
	if err := os.RemoveAll(dataDir); err != nil {
		log.Errorf("Error deleting data directory %s", err)
		return err
	}
	return nil
}
Exemple #2
0
func main() {
	ecc.Start(true, true, "eth1", dataDir)
	listener := eccListener{}
	go ecc.RegisterForNodeUpdates(listener)
	go ecc.RegisterForKeyUpdates("network", "web", listener)
	keyUpdates("web")
	ecc.Delete("network", "web")
	go ecc.RegisterForKeyUpdates("network", "db", listener)
	keyUpdates("db")
	keyUpdates("web")
	// Ctrl+C handling
	ecc.Leave()
	time.Sleep(time.Second * 15)
	ecc.Start(true, true, "eth1", dataDir)

	handler := make(chan os.Signal, 1)
	signal.Notify(handler, os.Interrupt)
	for sig := range handler {
		if sig == os.Interrupt {
			time.Sleep(1e9)
			break
		}
	}
}