upgrade

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package upgrade implements zero-downtime restarts by handing the listening sockets to a freshly-exec'd copy of the binary. The child inherits the bound listener file descriptors and starts accepting on them immediately, so the data-plane ports never close; the parent then drains its existing connections and exits.

Listeners participate by creating their sockets through ListenTCP / ListenUDP instead of binding directly: on a normal start these bind fresh and register the socket for later handoff; after an upgrade they transparently adopt the inherited socket matching their address.

Socket inheritance relies on passing file descriptors to a child process, which is only available on Unix-like systems. On other platforms an upgrade request returns an error and ListenTCP / ListenUDP simply bind fresh.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenTCP

func ListenTCP(addr string) (net.Listener, error)

ListenTCP returns a TCP listener for addr, adopting an inherited socket if one was passed by a parent process during an upgrade, otherwise binding fresh. The returned listener is registered for a future handoff.

func ListenUDP

func ListenUDP(addr string) (*net.UDPConn, error)

ListenUDP returns a UDP packet connection for addr, adopting an inherited socket if available, otherwise binding fresh, and registers it for handoff.

func Perform

func Perform() (pid int, err error)

Perform spawns a child process that inherits the registered listening sockets and starts serving on them. It returns the started child's PID. The caller should then gracefully drain and exit the current process. On platforms without FD passing it returns an error.

func Supported

func Supported() bool

Supported reports whether socket handoff is available on this platform.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL