migrated to external IP allocator

This commit is contained in:
ston1th 2021-09-26 20:20:43 +02:00
commit e2449b425e
15 changed files with 478 additions and 194 deletions

View file

@ -1,10 +1,12 @@
package main
import (
"errors"
"flag"
"os"
"os/signal"
"syscall"
"time"
"git.giftfish.de/ston1th/haproxy-lb/pkg/api"
"git.giftfish.de/ston1th/haproxy-lb/pkg/cluster"
@ -69,17 +71,26 @@ func main() {
}
}()
go func() {
sig := make(chan os.Signal)
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGHUP)
for {
<-sig
c.Stepdown()
}
}()
sigs := make(chan os.Signal)
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
s := <-sigs
log.Info("haproxy-lb shutdown", "signal", s.String())
go func() {
select {
case <-time.After(time.Second * 10):
log.Error(errors.New("shutdown took longer than 10 seconds"), "shutdown forced")
case <-sigs:
log.Error(errors.New("force shutdown triggerd"), "shutdown forced")
}
os.Exit(1)
}()
c.Stop()
log.Info("haproxy-lb stopped")
}