On Tue, 02.12.14 08:00, Nekrasov, Alexander (alexander.nekra...@emc.com) wrote:
> 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 No. systemd has a concept of "template" units, that can be instantiated a number of times. The unit names with "@" in the name are such templated units. The files on disk are name foo@.service, and at runtime you can then instantiate them as foo@bar.service, foo@waldo.service and so on. The "foo" in this scheme is the template name, while bar/waldo/... is the instance id. In my proposal below I suggested using one template and then instantiate them once for each failed unit, using the faile unit's name as the instance id. > > -----Original Message----- > > From: Lennart Poettering [mailto:lenn...@poettering.net] > > Sent: Monday, December 01, 2014 5:46 PM > > To: Nekrasov, Alexander > > Cc: systemd-devel@lists.freedesktop.org > > Subject: Re: [systemd-devel] reacting to unit failures (OnFailure) > > > > On Mon, 01.12.14 17:10, Nekrasov, Alexander (alexander.nekra...@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 > Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel