<div dir="auto">If your service gracefully exits and flushes buffers on SIGTERM then no requests will be lost. (That means. Finish off processing any requests that have been accept()'d before exiting).<div dir="auto"><br></div><div dir="auto">Any requests you didn't accept() yet will simply queue up whilst the service is down and you pick up where you left off after restart. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 28 Jul 2021, 10:08 Francis Moreau, <<a href="mailto:francis.moro@gmail.com" rel="noreferrer noreferrer" target="_blank">francis.moro@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Jul 27, 2021 at 11:12 AM Mantas Mikulėnas <<a href="mailto:grawity@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">grawity@gmail.com</a>> wrote:<br>
><br>
> On Tue, Jul 27, 2021 at 10:10 AM Francis Moreau <<a href="mailto:francis.moro@gmail.com" rel="noreferrer noreferrer noreferrer" target="_blank">francis.moro@gmail.com</a>> wrote:<br>
> ><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.<br>
><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>
Thank you for response.<br>
<br>
If the service only is restarted, will be there also requests that can be lost ?<br>
<br>
If the service is restarted then it's first stopped but in the<br>
meantime the socket unit should be listening for new requests...<br>
<br>
-- <br>
Francis<br>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" rel="noreferrer noreferrer noreferrer" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div>