Pass SIGTERM to the inner process for graceful shutdown
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
11
main.go
11
main.go
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user