MCPcopy Index your code
hub / github.com/bytebase/bytebase / stop

Function stop

backend/resources/postgres/postgres.go:54–71  ·  view source on GitHub ↗

stop stops a postgres instance, outputs to stdout and stderr.

(pgDataDir string)

Source from the content-addressed store, hash-verified

52
53// stop stops a postgres instance, outputs to stdout and stderr.
54func 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.
74func initDB(pgDataDir, pgUser string) error {

Callers 2

StartMetadataInstanceFunction · 0.85
StartAllSampleInstancesFunction · 0.85

Calls 2

shouldSwitchUserFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected