fixed gitignore

This commit is contained in:
ston1th 2020-11-12 02:13:01 +01:00
commit 16a145bef4
2 changed files with 63 additions and 1 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
data/
vipman
/vipman

62
cmd/vipman/main.go Normal file
View file

@ -0,0 +1,62 @@
package main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"time"
"git.giftfish.de/ston1th/vipman/pkg/cluster"
"git.giftfish.de/ston1th/vipman/pkg/config"
"k8s.io/klog"
"k8s.io/klog/klogr"
)
var (
configFile string
)
func main() {
klog.InitFlags(nil)
flag.StringVar(&configFile, "config", "vipman.yaml", "vipman config file")
flag.Parse()
cfg, err := config.ParseFile(configFile)
if err != nil {
klog.Fatalf("Initialization failed: %s", err)
}
c, err := cluster.InitCluster(cluster.LeaderCallbacks{
OnStartedLeading: func(ctx context.Context) {
ticker := time.NewTicker(time.Second * 10)
for {
select {
case <-ctx.Done():
return
case <-ticker.C:
}
klog.Infof("[%s] leading", cfg.LocalPeer.ID)
}
},
OnStoppedLeading: func() {
klog.Infof("[%s] stopped leading", cfg.LocalPeer.ID)
},
OnNewLeader: func(id string) {
klog.Infof("[%s] new leader: %s", cfg.LocalPeer.ID, id)
},
})
if err != nil {
klog.Fatalf("Initialization failed: %s", err)
}
log := klogr.New()
go func() {
err = c.StartRaftCluster(log, cfg)
if err != nil {
klog.Fatalf("Initialization failed: %s", err)
}
}()
sigs := make(chan os.Signal)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
<-sigs
c.Stop()
}