Why can't ExecStopPre= be used to abort stopping a (broken) service?

Paul Wouters pwouters at redhat.com
Mon Jul 15 22:15:55 UTC 2013


On Mon, 15 Jul 2013, "Jóhann B. Guðmundsson" wrote:

>> If I grok correctly what you are asking for, you are actually looing for
>> an ExecRestartPre=, not an ExecStopPre=. You want somthing that is run
>> before we stop a service when we intend to restart it. But when we
>> shutdown the system and stop the service for that, or if the user wants
>> to stop it manually, we shouldn't run it, correct?
>> 
>> If that's what you want, then yes, it is on the TODO list to add
>> something like this

Yes that is what I'm asking for. Great to know it is on the TODO.


> Adding that does not make much sense.
>
> For the first in 99% use cases are covered via ExecStartPre=

That does not cover the config file changing in a way that introduced an
error preventing the service from starting if it ever got stopped.

> Secondly the fact is that the admin would never notice the configuration 
> error because he
>
> Admin makes incorrect change to config file -->  then restart the service --> 
> the service would not fail

Yes the systemctl command would fail with an exit code. A syslog message
would be logged. The fact that the restart did not get to even call the
stop part does not mean the command returns without failure.


> The fact is the only way admin will notices and react to this, is if the 
> service will hard fail upon restart and systemd should not be working around 
> admin mistakes in configuration file.

That's great for the 1 admin or 1 machine solution, but does not work
when you script an update via puppet or ansible and it fails somehow on
some machines (eg let's see those machines have an older version of the
daemon and now the new config option kills it)

> The correct way here is to stay true to what is tried and tested in the 
> legacy sysv init scripts and add the config parser to the ExecStartPre= line 
> in the unit file.

I have that now, but it still causing the service to terminate after a
"restart", which I think is less desirable than running with the old
config. But again, with the option there, people can choose what they
prefer.

Paul


More information about the devel mailing list