Revert to SIGTERM and add SIGINT signal.
All checks were successful
continuous-integration/drone Build is passing
All checks were successful
continuous-integration/drone Build is passing
This commit is contained in:
19
main.go
19
main.go
@@ -19,7 +19,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const version = "1.1"
|
||||
const version = "1.2"
|
||||
const GroupStatePrimary = "primary"
|
||||
const GroupStatePrimaryDegraded = "wait_primary"
|
||||
const GroupStatePrimaryAlone = "single"
|
||||
@@ -278,21 +278,18 @@ func main() {
|
||||
cmd.Env = innerEnv
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
// Pass signals to the inner process
|
||||
// Pass termination signals to the inner process
|
||||
// Note: The container we are part sets STOPSIGNAL SIGINT but we accept also the default SIGTERM
|
||||
sigs := make(chan os.Signal, 1)
|
||||
signal.Notify(sigs)
|
||||
defer close(sigs)
|
||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||
defer signal.Reset()
|
||||
go func() {
|
||||
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)
|
||||
}
|
||||
log.Info("Passing signal '" + sig.String() + "' to the inner process")
|
||||
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.")
|
||||
|
||||
Reference in New Issue
Block a user