[systemd-devel] Smooth upgrades for socket activated services

Uoti Urpala uoti.urpala at pp1.inet.fi
Tue Feb 21 11:34:40 UTC 2023


On Mon, 2023-02-20 at 12:22 +0100, Mike Hearn wrote:
> I see. So basically you have to keep the service running across the
> upgrade and then wait for it to shut down due to inactivity, then be
> restarted by systemd to make the update apply. Or alternatively you
> could make the app detect that it's been updated, stop accepting new
> connections, finish servicing the old connections, and then shut
> itself down once all existing connections are finished. On restart
> it'd then be using the new code, re-accept the socket from systemd
> and start accepting again.

Instead of "detect that it's been updated", I believe a more common and
recommendable approach would be to make it part of the daemon's normal
clean shutdown (for daemons where this behavior is appropriate). That
is, stop accepting new connections from the listening socket, but
finish serving already accepted connections. Then the "restart" part
alone is enough to switch to a new version without losing connections
(at least if things don't take so long that connections time out).



More information about the systemd-devel mailing list