Skip to content

Commit

Permalink
fix: modify pg isDBStartReady (#4704)
Browse files Browse the repository at this point in the history
  • Loading branch information
kizuna-lek authored Aug 9, 2023
1 parent af350c1 commit 861c1c3
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions cmd/probe/internal/component/postgres/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,9 @@ func (mgr *Manager) IsDBStartupReady() bool {
return true
}

cmd := exec.Command("pg_isready")
if config.username != "" {
cmd.Args = append(cmd.Args, "-U", config.username)
}
if config.host != "" {
cmd.Args = append(cmd.Args, "-h", config.host)
}
if config.port != 0 {
cmd.Args = append(cmd.Args, "-p", strconv.FormatUint(uint64(config.port), 10))
}
err := cmd.Run()
err := mgr.Pool.Ping(context.TODO())
if err != nil {
mgr.Logger.Infof("DB is not ready: %v", err)
mgr.Logger.Warnf("DB is not ready, ping failed, err:%v", err)
return false
}

Expand Down

0 comments on commit 861c1c3

Please sign in to comment.