MCPcopy Index your code
hub / github.com/coder/coder / cleanStalePIDFile

Function cleanStalePIDFile

scripts/develop/dbrecovery.go:596–616  ·  view source on GitHub ↗
(dataDir string)

Source from the content-addressed store, hash-verified

594}
595
596func cleanStalePIDFile(dataDir string) {
597 pidPath := filepath.Join(dataDir, "postmaster.pid")
598 content, err := os.ReadFile(pidPath)
599 if err != nil {
600 return
601 }
602 lines := strings.SplitN(string(content), "\n", 2)
603 pid, err := strconv.Atoi(strings.TrimSpace(lines[0]))
604 if err != nil {
605 _ = os.Remove(pidPath)
606 return
607 }
608 proc, err := os.FindProcess(pid)
609 if err != nil {
610 _ = os.Remove(pidPath)
611 return
612 }
613 if err := proc.Signal(syscall.Signal(0)); err != nil {
614 _ = os.Remove(pidPath)
615 }
616}
617
618func currentMigrationVersion(ctx context.Context, db *sql.DB) (int, bool, error) {
619 var version int

Callers 2

startTempPostgresSetURLFunction · 0.85
TestCleanStalePIDFileFunction · 0.85

Calls 3

ReadFileMethod · 0.65
RemoveMethod · 0.65
SignalMethod · 0.65

Tested by 1

TestCleanStalePIDFileFunction · 0.68