0

I tried to restrict the number of a service (in a container) restart. The OS version is centos-release-7-5, the service file is pretty much as below (removed some parameters for reading convenience). It should be pretty straight forward as some other posts pointed out (Post of Server Fault restart limit 1 , Post of Stack Overflow restart limit 2 ). Yet StartLimitBurst and StartLimitIntervalSec never works for me.

I tested with several ways: (1) I check the service PID, kill the service with "kill -9 ****" several times. The service always gets restarted after 20s! (2) I also tried to mess up the service file, make the container never runs. Still, it doesn't work, the service file just keep restarting.

Any idea?

[Unit]
Description=Hello Fluentd
After=docker.service
Requires=docker.service
StartLimitBurst=2
StartLimitIntervalSec=150s

[Service]
EnvironmentFile=/etc/environment
ExecStartPre=-/usr/bin/docker stop "fluentd"
ExecStartPre=-/usr/bin/docker rm -f "fluentd"
ExecStart=/usr/bin/docker run fluentd
ExecStop=/usr/bin/docker stop "fluentd"
Restart=always
RestartSec=20s
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target
jww
  • 97,681
  • 90
  • 411
  • 885
batilei
  • 401
  • 3
  • 6
  • 16
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Aug 21 '18 at 09:26
  • I'm voting to close this question as it has been asked by the OP and answered successfully at https://unix.stackexchange.com/questions/463917/systemds-startlimitintervalsec-and-startlimitburst-never-work – Daniel W. Jan 27 '20 at 11:53

1 Answers1

-1

I posted the problem in UNIT stack exchange. Anyway in case somebody search it here, I also posted my answer here since I found the issue. All the doc online suggests those all parameters are in UNIT file (systemd unit file), but still in my system (centos 7.5), they are in service file. Besides the name is "StartLimitInterval", not "StartLimitIntervalSec".

batilei
  • 401
  • 3
  • 6
  • 16
  • There is actually a `StartLimitIntervalSec` but that only exists in sytemd version >= 230 https://lists.freedesktop.org/archives/systemd-devel/2017-July/039255.html – Chris Grimmett Jul 11 '22 at 19:04