This is not about ExecStartPre
One use case when tweaking services is to test a config file before restarting the service.
for example.
$ vim /etc/nginx.conf
$ nginx -t && restart_nginx
the equivalent with systemd is to still having to remember the check before issuing a restart.
Is there something that prevents that very-likely human error? something like ExecRestartStopPre
? That is, something it will execute before the stop step of a restart?
I wonder if you should be using
ExecReload
in this case? Add something like this to your service unit:This will only send the reload (
HUP
) signal to nginx if the configuration check passes. Unlikerestart
, this doesn't perform astop
orstart
on the service.Instead of running running
systemctl restart nginx
, you would runsystemctl reload nginx
.