Pass SIGTERM to the inner process for graceful shutdown
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-06-02 09:17:32 +00:00
parent 7170112853
commit a6fdae696d

11
main.go
View File

@@ -8,10 +8,12 @@ import (
"net/http"
"os"
"os/exec"
"os/signal"
"path/filepath"
"slices"
"strconv"
"strings"
"syscall"
"time"
log "github.com/sirupsen/logrus"
@@ -276,6 +278,15 @@ 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)
go func() {
for sig := range c {
log.Info("Passing signal " + sig.String() + " to the inner process")
cmd.Process.Signal(sig)
}
}()
cmd.Run()
log.Info("pg_auto_failover load balancer configurator has completed.")