Another SIGTERM try
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-06-02 11:25:59 +00:00
parent a6fdae696d
commit df450a7624

20
main.go
View File

@@ -19,7 +19,7 @@ import (
log "github.com/sirupsen/logrus"
)
const version = "1.0"
const version = "1.1"
const GroupStatePrimary = "primary"
const GroupStatePrimaryDegraded = "wait_primary"
const GroupStatePrimaryAlone = "single"
@@ -278,15 +278,21 @@ func main() {
cmd.Env = innerEnv
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
// Pass SIGTERM to the inner process
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM)
// Pass signals to the inner process
sigs := make(chan os.Signal, 1)
signal.Notify(sigs)
go func() {
for sig := range c {
log.Info("Passing signal " + sig.String() + " to the inner process")
cmd.Process.Signal(sig)
for sig := range sigs {
if sig != syscall.SIGCHLD {
log.Info("Passing signal " + sig.String() + " to the inner process")
syscall.Kill(-cmd.Process.Pid, sig.(syscall.Signal))
//cmd.Process.Signal(sig)
}
}
}()
// Create a dedicated pidgroup used to forward signals to
// main process and all children
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
cmd.Run()
log.Info("pg_auto_failover load balancer configurator has completed.")