[systemd-devel] Help regarding service dependency
Andrey Borzenkov
arvidjaar at gmail.com
Thu Mar 13 19:35:44 PDT 2014
В Thu, 13 Mar 2014 21:25:34 -0400 (EDT)
Amit Saha <asaha at redhat.com> пишет:
> Hello,
>
> We have service1 which starts in default.target, and we want it to start After service2
> (systemd-readahead-done) which starts after the default.target is reached.
> So, I think what would happen in this case is the After=service2 for service1 is ignored
> and it is started before service2 since the default.target must be reached.
>
There is no ordering dependencies between default.target and individual
units; default.target is simply a way to define what is started using
Wants. So it should work.
> For more specific info, here is a snippet of the .timer file for service2:
>
> [Unit]
> Description=Stop Read-Ahead Data Collection 10s After Completed Startup
> Documentation=man:systemd-readahead-replay.service(8)
> DefaultDependencies=no
> Conflicts=shutdown.target
> After=default.target
> Before=shutdown.target
> ConditionVirtualization=no
>
> [Timer]
> OnActiveSec=30s
>
>
> A colleague suggested creating a new target for service1 which
> the system boots into and has a After=default.target, systemd-readahead-done.service.
You seem to assume default.target is magic - it is not. If you boot
into another target, it becomes "default target" in this case.
> Even if not exactly how I mention, this idea holds promise.
>
> Also, is there any other suggested solution involving fiddling with the unit dependencies
> but not the system boot target?
>
No fiddling is required.
More information about the systemd-devel
mailing list