<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
<body>
<div name="messageReplySection">
<div dir="auto">Making the service reliable will require updating the clients of the service to retry the connection for some period of time while the service restarts.</div>
<blockquote style="border-left-color: rgb(26, 188, 156); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid;">
------------------------------<br>
<br>
Message: 4<br>
Date: Tue, 27 Jul 2021 12:12:43 +0300<br>
From: Mantas Mikul?nas <grawity@gmail.com><br>
To: Francis Moreau <francis.moro@gmail.com><br>
Cc: SystemD Devel <systemd-devel@lists.freedesktop.org><br>
Subject: Re: [systemd-devel] How to restart my socket activated<br>
service safely ?<br>
Message-ID:<br>
<CAPWNY8UxSmZSo7vUCk1WpXaSTvP4vtC4ucKM6iJSf9G06yHGFg@mail.gmail.com><br>
Content-Type: text/plain; charset="UTF-8"<br>
<br>
On Tue, Jul 27, 2021 at 10:10 AM Francis Moreau <francis.moro@gmail.com> wrote:<br>
<blockquote style="border-left-color: rgb(230, 126, 34); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid;">
<br>
Hello,<br>
<br>
During my application update, I want to restart my service which is<br>
activated by a socket but want to be sure that no request sent to my<br>
service will be missed. I also want to restart the socket too so<br>
systemd uses the latest version of the socket unit file.<br>
<br>
If I restart the socket when the service is still running then I get<br>
an error message: "rotor.socket: Socket service rotor.service already<br>
active, refusing."<br>
<br>
If I stop the service first and restart the socket then there's a<br>
short time frame where requests can be lost.</blockquote>
<br>
The old socket has to be unbound before a new one can be put in its<br>
place. Trying to keep the service alive (holding the old listener fd)<br>
would just result in systemd not being able to bind a new socket with<br>
the same address... (And even if that was possible, the old service<br>
wouldn't be able to handle requests arriving on the new socket<br>
anyway.)<br>
<br>
So whenever you restart a socket, there will *always* be a short time<br>
frame where the old socket is closed but the new one is not yet<br>
bound/listening. But as soon as the new one is listening, it'll start<br>
queuing the requests even if the service isn't yet running (since it's<br>
a socket-activated service after all) and the number of lost requests<br>
should be minimal.<br>
<br>
--<br>
Mantas Mikul?nas<br>
<br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
systemd-devel mailing list<br>
systemd-devel@lists.freedesktop.org<br>
https://urldefense.com/v3/__https://lists.freedesktop.org/mailman/listinfo/systemd-devel__;!!N0rdg9Wr!5lTR7wKPcVtYGDel8mKxXIT0K2BICEZ0RIZKAQT5duI149oGAdk1Ci3yH_m2j7SaKTo$<br>
<br>
<br>
------------------------------<br>
<br>
End of systemd-devel Digest, Vol 135, Issue 24<br>
**********************************************</blockquote>
</div>
</body>
</html>