2

I facing the same problem (which is similar to https://stackoverflow.com/questions/41908660/systemd-always-have-a-service-running-and-reboot-if-service-stops-more-than-x), having following service. I made my service failing every minute (means it does not send notify signal) so service is restarted but it never reboot the system. Any Idea?

[Service]
#Type=simple
Type=notify
NotifyAccess=all
#ExecStartPre=/sbin/modprobe bcm2835-v4l2
ExecStart=/usr/java/default/bin/java -Xms150m -Xmx150m \
-Djava.library.path=/home/pi/opencv-3.1.0/build/lib:/usr/local/src/openalpr/src/bindings/java:/home/pi/compile/raspicam-0.1.3/src/jni/:/home/pi/co
-Dcom.sun.management.jmxremote.port=3333 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Djava.rmi.server.hostname=172.16.16.139 \
-jar /home/pi/garageSystem.jar eu /home/pi/alpr.conf /usr/local/src/openalpr/runtime_data/ /home/pi/conf/

Restart=on-failure
#Restart=always
RestartSec=1
WatchdogSec=60s


#OnFailure=systemd-reboot

StartLimitIntervalSec=5m
StartLimitBurst=1
StartLimitAction=force-reboot

[Install]
WantedBy=multi-user.target

Additional system info

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.9.14-v7+ #977 SMP Mon Mar 13 18:25:19 GMT 2017 armv7l GNU/Linux
pi@raspberrypi:~ $ sudo systemd --version
systemd 215
+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR

Update:

I have probably found solution for my case, when I need to reboot device, when service fail. Since systemd from version 213 https://lists.freedesktop.org/archives/systemd-commits/2014-May/006228.html) supports FailureAction=reboot , which works the same as StartLimitAction but on every fail = thats what I wanted. But it nothing changes, that StartLimitAction does not work. Do u think, it is a bug?

  • Have you used systemd-analyze verify ./path/to/your/file.service to see if there any warnings or errors with your service file? – Mark Stosberg Mar 18 '17 at 16:20
1

According to man systemd.unit, the correct value for StartLimitAction= is reboot-force. But you have used force-reboot, which is not a valid option.

systemd will report this problem if you use systemd-analyze verify:

systemd-analyze verify ./path/to/your/file.service
[/etc/systemd/system/test.service:4] Failed to parse failure action specifier, ignoring: force-reboot
  • Yes, thats correct! But i was also using only reboot command. but I will verify it – Tomas Bilek Mar 19 '17 at 7:29
  • So i have change it to StartLimitIntervalSec=5m StartLimitBurst=1 StartLimitAction=reboot-force, do nothing, also if StartLimitAction is set to "reboot". Running "systemd-analyze verify garage.service" gives output "Unknown operation 'verify'." I have checked manual and there is not such commend – Tomas Bilek Mar 19 '17 at 7:37
  • Just one more question, is there any "internal" log of systemd where is written, what is it performing? I mean, that if there is something what could tell me StartLimitBurst was reached and StartLimitAction is performed? – Tomas Bilek Mar 19 '17 at 8:25
  • You can use journalctl to read the systemd journal. I don't know what it will log about those actions. You'll have to check /etc/systemd/journald.conf` to confirm the systemd journald logs are persisting through reboots. – Mark Stosberg Mar 19 '17 at 12:49
  • 1
    OK, i will try to update it, but before posting I have performed all update commands, so I will try to update it to the latest one and return back. But thank you anyway. – Tomas Bilek Mar 21 '17 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.