| 594 | } |
| 595 | |
| 596 | func 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 | |
| 618 | func currentMigrationVersion(ctx context.Context, db *sql.DB) (int, bool, error) { |
| 619 | var version int |