stop stops a postgres instance, outputs to stdout and stderr.
(pgDataDir string)
| 52 | |
| 53 | // stop stops a postgres instance, outputs to stdout and stderr. |
| 54 | func stop(pgDataDir string) error { |
| 55 | p := exec.Command("pg_ctl", "stop", "-w", "-D", pgDataDir) |
| 56 | uid, _, sameUser, err := shouldSwitchUser() |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } |
| 60 | if !sameUser { |
| 61 | p.SysProcAttr = &syscall.SysProcAttr{ |
| 62 | Setpgid: true, |
| 63 | Credential: &syscall.Credential{Uid: uid}, |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // Suppress log spam |
| 68 | p.Stdout = nil |
| 69 | p.Stderr = os.Stderr |
| 70 | return p.Run() |
| 71 | } |
| 72 | |
| 73 | // initDB inits a postgres database if not yet. |
| 74 | func initDB(pgDataDir, pgUser string) error { |
no test coverage detected