[systemd-devel] Dependencies on targets

Andrei Borzenkov arvidjaar at gmail.com
Wed Feb 10 04:58:23 CET 2016


10.02.2016 00:55, Pathangi Janardhanan пишет:
> 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
> 
>  and in the t21.service and t22.service, I have
>  Wants=t2.target
> 
> 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 services are unknown in advance, there is no easy way to do it. This
is recurring question, and so far position of systemd developers was "if
you need it you do something wrong" :/

>  If I change the t21.service and t22.service to include
> 
>  Requires=t2.target
>  After=t2.target
> 
>  Things work as expected, i.e. all services in t1.target get started and
> ready before services t21 and t22 are started
> 

Yes, of course. Now t2.target serves as boundary line; one set of
services is started before it, another set of services is started after
it. Of course now you will have a problem if you have third set of
services that should be started after t2 set ...

>  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.
> 

It cannot be done using one target only. For units shipped with systemd
two targets are used, like local-fs-pre.target and local-fs.target, and
services are ordered between them. Like

t1.target
Before=t2-pre.target

t21.service
After=t2-pre.target



More information about the systemd-devel mailing list