[systemd-devel] reacting to unit failures (OnFailure)

Nekrasov, Alexander alexander.nekrasov at emc.com
Tue Dec 2 05:00:52 PST 2014


Meaning that I have to create a myfailureunit<name>.service file/unit for every unit I want to register for? Which in my case is going to be almost all of them, in a high availability system

> -----Original Message-----
> From: Lennart Poettering [mailto:lennart at poettering.net]
> Sent: Monday, December 01, 2014 5:46 PM
> To: Nekrasov, Alexander
> Cc: systemd-devel at lists.freedesktop.org
> Subject: Re: [systemd-devel] reacting to unit failures (OnFailure)
> 
> On Mon, 01.12.14 17:10, Nekrasov, Alexander (alexander.nekrasov at emc.com)
> wrote:
> 
> > Hello,
> >
> > While converting from Upstart to SystemD, came upon this issue. Is
> this case not covered or am I missing something?
> >
> > In Upstart, I can start a job when another job fails, and there's a
> $JOB variable that tells me what was the job that failed.
> >
> > start on (stopped RESULT=failed PROCESS=post-stop)
> >
> > script
> >     echo "this just failed: $JOB"
> > end script
> >
> > In SystemD I can register a unit to be started when another unit
> > fails. But there seems to be no way of knowing what unit failed. Is
> > that correct?
> 
> The idea is that you use "OnFailure=myfailureunit@%n.service". %n is
> automatically replaced by the name of the unit you place this
> in. Then, in the failure unit you can identify the instance again with
> %i or %I.
> 
> Lennart
> 
> --
> Lennart Poettering, Red Hat


More information about the systemd-devel mailing list