How to automagically restart PHP-FPM if it crashes (Debian)

I switched to php7.3-fpm, which is noticably faster than the old fpm. Sadly, it sometimes crashes which leads to ugly error messages until I restart the server:

Fortunately, there exists a trick to adapt the systemd config file:

sudo systemctl edit php7.3-fpm 

this will open an editor where you can type additions to the service definition. Simply add the following to make the service restart automatically:

[Service]
Restart=on-failure

After saving the file, it should end up in /etc/systemd/system/php7.3-fpm.service.d/override.conf. Reloading systemd is not required. Let’s test:

# service php7.3-fpm status
● php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/php7.3-fpm.service.d
└─override.conf
Active: active (running) since Wed 2019-01-23 14:36:08 CET; 49s ago
Docs: man:php-fpm7.3(8)
Main PID: 14191 (php-fpm7.3)
...
# kill -11 14191
# service php7.3-fpm status
● php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/php7.3-fpm.service.d
└─override.conf
Active: active (running) since Wed 2019-01-23 14:41:32 CET; 1s ago
Docs: man:php-fpm7.3(8)
Main PID: 15517 (php-fpm7.3)
...