MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / reloadPostgres

Function reloadPostgres

internal/sqltest/native/postgres.go:168–190  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

166}
167
168func 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
192func waitForPostgres(ctx context.Context, uri string, timeout time.Duration) error {
193 deadline := time.Now().Add(timeout)

Callers 1

configurePostgresFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected