| 166 | } |
| 167 | |
| 168 | func reloadPostgres() error { |
| 169 | // Try systemctl reload |
| 170 | cmd := exec.Command("sudo", "systemctl", "reload", "postgresql") |
| 171 | if err := cmd.Run(); err == nil { |
| 172 | return nil |
| 173 | } |
| 174 | |
| 175 | // Try service reload |
| 176 | cmd = exec.Command("sudo", "service", "postgresql", "reload") |
| 177 | if err := cmd.Run(); err == nil { |
| 178 | return nil |
| 179 | } |
| 180 | |
| 181 | // Try pg_ctlcluster reload |
| 182 | output, _ := exec.Command("ls", "/etc/postgresql/").CombinedOutput() |
| 183 | versions := strings.Fields(string(output)) |
| 184 | if len(versions) > 0 { |
| 185 | cmd = exec.Command("sudo", "pg_ctlcluster", versions[0], "main", "reload") |
| 186 | return cmd.Run() |
| 187 | } |
| 188 | |
| 189 | return fmt.Errorf("could not reload PostgreSQL") |
| 190 | } |
| 191 | |
| 192 | func waitForPostgres(ctx context.Context, uri string, timeout time.Duration) error { |
| 193 | deadline := time.Now().Add(timeout) |