0

When using Supervisor there are a couple of plugins available that are able to restart an application if it's using to much memory (-> memory leak at e.g. some Java-tools) or if the application is not responding (even though it's not officially crashed). I'm looking for a nice way to do it on SystemD-level, too. Is there anyone one can give SystemD a command to recognize a started application is still functioning? Maybe similar to the ExecStartPost option.

frlan
  • 573
  • 1
  • 8
  • 27

1 Answers1

0

You can use a watchdog for services :

WatchdogSec=

Configures the watchdog timeout for a service. The watchdog is activated when the start-up is completed. The service must call sd_notify(3) regularly with "WATCHDOG=1" (i.e. the "keep-alive ping"). If the time between two such calls is larger than the configured time, then the service is placed in a failed state and it will be terminated with SIGABRT (or the signal specified by WatchdogSignal=). By setting Restart= to on-failure, on-watchdog, on-abnormal or always, the service will be automatically restarted. The time configured here will be passed to the executed service process in the WATCHDOG_USEC= environment variable. This allows daemons to automatically enable the keep-alive pinging logic if watchdog support is enabled for the service. If this option is used, NotifyAccess= (see below) should be set to open access to the notification socket provided by systemd. If NotifyAccess= is not set, it will be implicitly set to main. Defaults to 0, which disables this feature. The service can check whether the service manager expects watchdog keep-alive notifications. See sd_watchdog_enabled(3) for details. sd_event_set_watchdog(3) may be used to enable automatic watchdog notification support.

you can find a lot of examples on the web.