----- Original Message ----- > From: "Lennart Poettering" <lenn...@poettering.net> > To: "Amit Saha" <as...@redhat.com> > Cc: "systemd Mailing List" <systemd-devel@lists.freedesktop.org> > Sent: Tuesday, March 25, 2014 7:49:08 AM > Subject: Re: [systemd-devel] Help regarding service dependency > > On Thu, 13.03.14 21:25, Amit Saha (as...@redhat.com) wrote: > > > 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. > > > > 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. > > 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? > > Note entirely sure I grok what you want to do, but note that if a unit > is pulled in by a target unit via Wants= and both the unit and the > target unit DefaultDependencies=yes (which is the default), then you > will implicitly get an After= added too, so that the target unit is only > reached after the unit is started. > > Or in other words: if you want to order a unit foo.service *after* a > target bar.target you want to pull it in from, then you need to set > DefaultDependencies=no and After=bar.target in it. > > The unit you listed above does exactly that, if you look closely.
Thanks Lennart. That solves what I wanted to achieve. For the record, here is how my service now looks like: [Unit] Description=The Beaker Harness server. After=network.target NetworkManager-wait-online.service time-sync.target systemd-readahead-done.service multi-user.target Requires=beah-beaker-backend beah-fwd-backend DefaultDependencies=no [Service] Type=simple ExecStart=/usr/bin/beah-srv KillMode=process The key changes are: DefaultDependencies=no And, adding multi-user.target in "After" After the above, this service starts after the readahead colllection is completed which is what I wanted to achieve. Best, Amit. _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel