[systemd-devel] start service only on specific exit status of some prog

Nick Jones nick.jones at network-box.com
Wed Aug 24 22:09:02 PDT 2011


On Wed, 2011-08-24 at 21:21 +0200, Lennart Poettering wrote: 
> On Wed, 24.08.11 21:12, Marius Tolzmann (tolzmann at molgen.mpg.de) wrote:
> 
> > 
> > On 24.08.2011 18:52, Lennart Poettering wrote:
> > >Hmm, yeah, if ExecStartPre= we put the unit in failure mode.
> > >
> > >So, let me see if I got this right: you are looking for something like
> > >ExecStartPre= but twhere the program when it returns non-zero should
> > >just cause the service to be skipped but not be put in failure state?
> > 
> > Yes. that's my request.
> > 
> > something like ConditionExec=/bin/true and ConditionExec=/bin/false
> > so i can implement any thinkable logic outside of systemd and still
> > maintain access to all features like Restart= etc.
> > 
> > I thought this may be an easy way to expand the already existent
> > conditions (ConditionPathExists= etc.)  without implementing too
> > many special conditional tests in systemd itself. (e.g. check if the
> > current hostname matches some pattern - which was my original issue
> > i tried to solve) 8)
> 
> I have now added this to the TODO list. It won't be easy to add this
> though, as execution extrernal processes synchronously is not an
> option. More likely I'll add an additional prefix char to ExecStart=
> (like "-") which would indicate skip-on-fail or so.
> 
> Lennart
> 

Would it make sense to emit a virtual unit label if a given unit fails?
For example if X.service fails during its execution, then the virtual
target X.service.failed is emitted.

Then another service can 'want' X.target.failed

In addition, (and sorry if this is already a feature, I've lost track)
a unit can 'Conflict' or be 'BlockedBy' or 'DontWant' another label.
This provides enough boolean logic to model complex conditions with
systemd units.

The ugly side is that a package might end up with a number of service
files that do almost the same thing, or require a forest of symlinks, to
enable behaviour based on the outcomes of dependent units.

Nick



More information about the systemd-devel mailing list