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

Lennart Poettering lennart at poettering.net
Wed Aug 24 09:52:24 PDT 2011


On Wed, 24.08.11 18:25, Marius Tolzmann (tolzmann at molgen.mpg.de) wrote:

> 
> On 24.08.2011 16:01, Lennart Poettering wrote:
> >On Tue, 02.08.11 17:06, Marius Tolzmann (tolzmann at molgen.mpg.de) wrote:
> >>
> >>is there a way to execute a program and take its exit status to
> >>evaluate the condition? like ConditionExec or whatever.
> >>
> >>is this already possible without getting a "failed" service?
> >
> >Hmm, so I think we should make sure that systemd unit files don't become
> >a programming language. i.e. there needs to be a limit on what we want
> >to allow to be expressed in unit files. I am tempted to say that checks
> >like this are probably beyond that limit, and fall into the domain where
> >shell scripts should be used. I.e. write a tiny shell script that is
> >executed in ExecStartPre invokes your tool, checks the return code and
> >then fails if needed.
> 
> Hi... thanks for the reply..
> 
> i really don't want to implement complex checks within unit files..
> but currently systemd lacks a clean possibility to implement complex
> checks outside of unit files.
> 
> I first tried the StartExecPre= approach.. but it turns out to be
> somehow destructive in combination with Restart=always.. and you end
> with a failed service.

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?

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list