Systemd Socket Activation: Can Reload Preserve Existing Connections?
0 reputation · 18 Apr 2021, 10:35 UTC
The application is a small Unix daemon that relies on a single TCP socket. The objective is to upgrade the binary to a newer version while keeping the service available to existing clients.
Systemd supports socket activation, allowing the service to be started on demand and to inherit the listening socket. Reloading the unit with systemctl reload restarts the executable, but documentation does not guarantee that the old process will hand off the socket to the new one without closing existing connections. Reports suggest that on some systemd releases the socket may be closed immediately, causing a reset for clients, whereas newer releases may allow a graceful hand‑over if the service implements proper signal handling. The behavior also depends on the ExecReload implementation.
Given these uncertainties, the key questions are:
1) Does systemd guarantee that a socket‑activated service can preserve active connections across a reload, or is it up to the service to implement a graceful hand‑over?
2) How does the behavior differ between systemd v237, v240, and v252, and can we rely on a specific release for this feature?
3) What minimal unit configuration or ExecReload script is required to achieve zero‑downtime reloads with socket activation?