Skip to content

Commit

Permalink
Show postgres command output
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 committed Aug 21, 2023
1 parent d5b014b commit 1a67588
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/internal/database/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ func (db *Postgres) Upgrade() error {
cmd := exec.Command(postgresInitDBCmd, "-D", newDataDirTemp)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
out, err := cmd.CombinedOutput()
err = cmd.Run()
if err != nil {
db.log.Infow("unable to run initdb on new new datadir, skipping upgrade", "error", err)
return nil
}
db.log.Infow("new database directory initialized", "output", string(out))
db.log.Infow("new database directory initialized")

// restore old pg_hba.conf
pgHBAConf, err := os.ReadFile(path.Join(db.datadir, "pg_hba.conf"))
Expand Down Expand Up @@ -306,12 +306,12 @@ func (db *Postgres) Upgrade() error {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = "/data"
out, err = cmd.CombinedOutput()
err = cmd.Run()
if err != nil {
db.log.Infow("unable to run pg_upgrade on new new datadir, abort upgrade", "error", err)
return nil
}
db.log.Infow("pg_upgrade done", "output", string(out))
db.log.Infow("pg_upgrade done")

// rm -rf /data/postgres
err = os.RemoveAll(db.datadir)
Expand Down

0 comments on commit 1a67588

Please sign in to comment.