Skip to content
This repository has been archived by the owner on Apr 14, 2019. It is now read-only.

Commit

Permalink
don't block on switchover
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Aug 9, 2017
1 parent da2ecac commit 3ace548
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pgha/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ func execRepmgrPromote(timeout int) {
if err := exec.CommandContext(ctx, "repmgr", "standby", "promote").Run(); err != nil {
log.Warningf("repmgr standby promote failed %s", err.Error())
log.Info("trying repmgr standby switchover")
execRepmgrSwitchover(timeout)
go execRepmgrSwitchover()
}
}

func execRepmgrSwitchover(timeout int) {
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Second)
defer cancel()
func execRepmgrSwitchover() {

if err := exec.CommandContext(ctx, "repmgr", "standby", "switchover").Run(); err != nil {
log.Fatalf("repmgr standby switchover failed %s", err.Error())
if err := exec.Command("repmgr", "standby", "switchover").Run(); err != nil {
log.Warningf("repmgr standby switchover failed %s", err.Error())
}
}

Expand Down

0 comments on commit 3ace548

Please sign in to comment.