The following is the GNU All-permissive License as recommended in

Copyright (C) 2024 Free Software Foundation

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.

Contributions are welcome. See

Auto-restart services

For non-systemd-native services like apache2 or coturn, you can implement the systemd behavior of auto-restart services by adding a config override:

cat /etc/systemd/system/coturn.service.d/override.conf

You can add that with systemctl edit coturn.service or apply via ansible like in commit [master 454c0a8] Autorestart coturn on failure

For a normal service where systemd correctly detects that the service is failed when the process died, you only need to add:


Note, that to restart forever, RestartSec will need to be >=3s, because of the defaults listed in /etc/systemd/system.conf:


If you want to restart faster, you need to change those values, for example:


However, you may also want to consider setting StartLimitAction= (man systemd.unit) to reboot the system.