This commit is contained in:
18
main.go
18
main.go
@@ -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 {
|
||||
for sig := range sigs {
|
||||
if sig != syscall.SIGCHLD {
|
||||
log.Info("Passing signal " + sig.String() + " to the inner process")
|
||||
cmd.Process.Signal(sig)
|
||||
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.")
|
||||
|
||||
Reference in New Issue
Block a user