From: =?UTF-8?Q?Samuli_Sepp=c3=a4nen?= References: <20170906235202.26551-1-davids@...515...> <20170907061646.GD70062@...1296...> <79762b44-c8c8-b765-1711-22ba3f210af0@...515...> Message-ID: <1e1b1ed5-5a4e-5234-1e57-06a609a6f2b9@...515...> Date: Thu, 7 Sep 2017 11:04:01 +0300 MIME-Version: 1.0 In-Reply-To: <79762b44-c8c8-b765-1711-22ba3f210af0@...515...> Content-Language: en-US Subject: Re: [Openvpn-devel] [PATCH] systemd: Enable systemd's auto-restart feature for server profiles List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: Gert Doering , David Sommerseth Cc: openvpn-devel@lists.sourceforge.net On 07/09/2017 10:16, Samuli Sepp=E4nen wrote: > On 07/09/2017 09:16, Gert Doering wrote: >> Hi, >> >> On Thu, Sep 07, 2017 at 01:52:02AM +0200, David Sommerseth wrote: >>> @@ -18,6 +18,8 @@ DeviceAllow=3D/dev/net/tun rw >>> ProtectSystem=3Dtrue >>> ProtectHome=3Dtrue >>> KillMode=3Dprocess >>> +RestartSec=3D5s >>> +Restart=3Don-failure >> >> Is there a way to get exponential backoff on restart? >> >> Restarting is good, but if there is something faulty that leads to >> "the process always dies right away", this can lead to very quickly >> filling disks with not-so-useful logging... >> >> (Otherwise, yes, restarting is good :-) ) >> >=20 > Hi, >=20 > From systemd.unit man-page[1]: >=20 > StartLimitIntervalSec=3D, StartLimitBurst=3D >=20 > Configure unit start rate limiting. By default, units which are > started more than 5 times within 10 seconds are not permitted to > start any more times until the 10 second interval ends. >=20 > I verified this behavior on CentOS 7 using another daemon (monit) by > setting "Restart=3Don-failure" for it, breaking its config file and > forcibly killing it. Note that RestartSec is the default, i.e. 100ms: >=20 > --- >=20 > Sep 07 09:55:37 centos-7 systemd[1]: monit.service: control process > exited, code=3Dexited status=3D1 >=20 > Sep 07 09:55:37 centos-7 systemd[1]: Unit monit.service entered failed > state. >=20 > Sep 07 09:55:37 centos-7 systemd[1]: monit.service holdoff time over, > scheduling restart. >=20 > Sep 07 09:55:37 centos-7 systemd[1]: Stopping Pro-active monitoring > utility for unix systems... >=20 > Sep 07 09:55:37 centos-7 systemd[1]: Starting Pro-active monitoring > utility for unix systems... >=20 > Sep 07 09:55:37 centos-7 systemd[1]: monit.service start request > repeated too quickly, refusing to start. >=20 > Sep 07 09:55:37 centos-7 systemd[1]: Failed to start Pro-active > monitoring utility for unix systems. >=20 > Sep 07 09:55:37 centos-7 systemd[1]: Unit monit.service entered failed > state. >=20 > --- >=20 > As you can see, systemd quickly realizes that monit will not come back > up and stops trying. >=20 > However, when I added "RestartSec=3D5s" the StartLimit* thresholds were > never triggered. This meant that systemd never ceased trying to restart > the monit service. >=20 > David: any particular reason why you added RestartSec? Why not just let > it be the default (100ms)? >=20 Actually the man-page quote above is a bit ambiguous. But later on the man-page explain the logic pretty clearly: "Note that units which are configured for Restart=3D and which reach the start limit are not attempted to be restarted anymore; however, they may still be restarted manually at a later point, from which point on, the restart logic is again activated." --=20 Samuli Sepp=E4nen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock