[systemd-devel] Q: handling generator-like dependency: target won't start on boot

Ulrich Windl Ulrich.Windl at rz.uni-regensburg.de
Wed Sep 28 06:25:04 UTC 2022


Hi!

I'm trying to establish a mechanism that uses a generator-like mechanism as described below. Unfortunately it starts when triggering the target manually, but it never starts on system boot. I could need some advice how to make it work.

Basically I have a generator-like unit, say "g.servive", that creates other instance-like services like i at .service.
Finally I have a target, say "t.target", that wants (among others) those instance-like services and is wanted by default.target.

As said in the beginning: When booting the target does not start (and I don't see any errors logged), but when I "systemctl start t.target", everything starts up fine.

More details:

generator-like services:
WantedBy default.target and t.target, and it "Wants=nss-user-lookup.target time-sync.target  paths.target" (the Before= list is identical). In addition it has "Before=default.target t.target".
It starts a "oneshot" script that creates the instance-like services with RemainAfterExit=true.

instance-like services:
PartOf=t.target, Requires generator-like.service (also After that service). In addition it "Wants=nss-user-lookup.target time-sync.target paths.target" (After= uses the same list). The service is Type=forking, and the unit is WantedBy=t.target

The script used in the generator-like service creates the unit files in /run/systemd/system, and it runs "/usr/bin/systemctl daemon-reload" whenever a unit file had been created or changed.

Could be problem be a race-condition, caused by daemon-reload being run asynchronously, i.e.: The generator-like service unit ends while the actual daemon-reload is still in progress?

systemd version is from SLES12 SP5 (systemd-228-157.40.1.x86_64).

Regards,
Ulrich





More information about the systemd-devel mailing list