()
| 698 | // parent process, if any) and to systemd. |
| 699 | if upg.HasParent() { |
| 700 | // We're the new process after an upgrade. Tell systemd our PID before |
| 701 | // signaling Ready to the parent — the parent may exit shortly after. |
| 702 | if err := sdNotify(fmt.Sprintf("MAINPID=%d\nREADY=1", os.Getpid())); err != nil { |
| 703 | slog.Warn("sd_notify MAINPID+READY failed.", "error", err) |
| 704 | } |
| 705 | } else { |
| 706 | if err := sdNotify("READY=1"); err != nil { |
| 707 | slog.Warn("sd_notify READY failed.", "error", err) |
| 708 | } |
| 709 | } |
| 710 | if err := upg.Ready(); err != nil { |
| 711 | slog.Error("Failed to signal readiness.", "error", err) |
| 712 | os.Exit(1) |
| 713 | } |
| 714 | |
| 715 | slog.Info("Control plane listening.", |
| 716 | "pg_addr", cp.pgListener.Addr().String(), |
| 717 | "worker_backend", cfg.WorkerBackend, |
| 718 | "process_min_workers", processMinWorkers, |
| 719 | "process_max_workers", processMaxWorkers, |
| 720 | "worker_queue_timeout", cfg.WorkerQueueTimeout, |
| 721 | "session_init_timeout", cfg.SessionInitTimeout, |
| 722 | "memory_budget", formatBytes(rebalancer.memoryBudget), |
| 723 | "memory_rebalance", cfg.MemoryRebalance) |
| 724 | |
| 725 | // Accept loop in background |
| 726 | go cp.acceptLoop() |
| 727 | |
| 728 | // Block until a successful upgrade causes tableflip to signal exit. |
| 729 | // SIGTERM/SIGINT are handled above and call os.Exit directly. |
| 730 | <-upg.Exit() |
no test coverage detected