[systemd-devel] Dependencies on targets

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Wed Feb 10 04:27:32 CET 2016


On Tue, Feb 09, 2016 at 04:55:45PM -0500, Pathangi Janardhanan wrote:
> Hi All,
> 
>  I have a target t1, which has three services associated with it, t11, t12
> and t13. The service dependencies After etc. I have in the individual t11,
> t12 and t13 unit files
> 
>  I have another target t2, which has two service associated with it t21,
> t22. I want all units associated with target t2 to start only after all
> units in target t1 are ready.
> 
>  So in t2.target , i have

>  Requires=t1.target
>  After=t1.target
This shouldn't be needed.

>  and in the t21.service and t22.service, I have
>  Wants=t2.target
This also shouldn't be needed, unless you want the start of e.g. t21.service
to also pull in t22.service. Normally you'd start t2.target and this would
pull in everything.

> and in Install section
>  WantedBy=t2.target
> 
>  But with this I find all the services that I want associated with t2,
> start right along with the services in t1.
> 
>  If I change the t21.service and t22.service to include
> 
>  Requires=t2.target
>  After=t2.target
Try: Requires=t1.target, After=t1.target.

>  Things work as expected, i.e. all services in t1.target get started and
> ready before services t21 and t22 are started
> 
>  So I would like to know if this is the correct way to order the dependency
> on the target, because if say After=t2.target, though it is actually (at
> least my intention) is that this service is associated with t2.target.
There are many ways to skin the cat, so to speak, but what
I wrote above would be standard way.

> I have also attached all the service and target files for reference.
You attached the files as binary/octet-stream. I'm too lazy too look
at them since they don't display inline ;)

Zbyszek


More information about the systemd-devel mailing list