[systemd-devel] reacting to unit failures (OnFailure)
lennart at poettering.net
Mon Dec 1 14:46:13 PST 2014
On Mon, 01.12.14 17:10, Nekrasov, Alexander (alexander.nekrasov at emc.com) wrote:
> 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)
> 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 Poettering, Red Hat
More information about the systemd-devel