[systemd-devel] Behavior of RestartSec= & Restart= parameters

Lennart Poettering lennart at poettering.net
Wed May 6 14:21:41 UTC 2020


On Sa, 11.04.20 19:51, Tiwari, Hari Sahaya (hari-sahaya.tiwari at hpe.com) wrote:

> Hi,
>
> I had a query on RestartSec= & Restart= parameters and how they work with StartLimitInterval= & StartLimitBurst= parameters.
>
> I have a socket-service pair (say test.socket & test.service)
>
> test.socket
> [Unit]
> Description=Test socket
>
> [Socket]
> ListenDatagram=123
> Accept=No
>
> [Install]
> WantedBy=sockets.target
>
> test.service
> [Unit]
> Description=test service
> Requires=test.socket
>
> [Service]
> Type=simple
> ExecStart=/bin/mytest
> StandardInput=socket
>
> [Install]
> WantedBy=multi-user.target
>
>
> I see that the test.socket fails with following error,
> systemd[1]: test.service: Start request repeated too quickly.
> systemd[1]: test.service: Failed with result 'exit-code'.
> systemd[1]: Failed to start test service.
> systemd[1]: test.socket: Failed with result 'service-start-limit-hit'.
>
> The test.socket fails after trying to start test.service for 5 times.
> I think this this is due to the default values of StartLimitInterval= & StartLimitBurst= which are 10sec and 5 respectively.
> The test.service restart is attempted even though there is no
> "Restart=" parameter is specified in the file.

It is restarted as long as there is still data enqueued in the
socket. which means if your service aborts before it takes any
datagram out of the socket it will busy loop until the start limit is
hit.

> So, this means StartLimitInterval= & StartLimitBurst= are not
> dependent on "Restart=" parameter? Is my understanding correct ?

They apply on any kind of starts. That's why it's called
StartLimitXYZ= and not RestartLimitXYZ=…

> Is there a way to add a delay before attempting to restart the service without specifying "Restart=" parameter?
> As per my understanding "RestartSec=" works only when "Restart="
> parameter is set to some value.

This currently does not exist. Consider filing an RFE issue on github
asking for this feature.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list