3

I've tried out 2 systemd unit configurations:

progA.service

[Service]
Type=simple
ExecStart=/opt/progA
WatchdogSec=10s

progB.service

[Service]
Type=simple
ExecStart=/opt/progB
Restart=always
RestartSec=10

The effect in 2 cases is similar: whenever the program killed/crashes/exits, it is restarted after 10s. To my understanding, using watchdog has advantage only if a specific thread/loop inside the program need to be monitored. Am I missing something?

1 Answers1

0

Yes, the watchdog will detect "liveness" above and beyond the Restart directive, which only detects "deadness".

In order to avoid being killed by the watchdog, your service must actively call sd_notify. Imagine if something bad happens that doesn't quite kill your service, like a deadlock. The process would not be killed with a Restart directive, but it would fail to send the sd_notify and would be restarted by the watchdog (as long as the checkups are being sent on the same thread that is deadlocked).

pneumatics
  • 2,836
  • 1
  • 27
  • 27