[systemd-devel] Difference between After and RequiredBy

Colin Guthrie gmane at colin.guthr.ie
Tue Nov 29 08:32:01 PST 2011


'Twas brillig, and Edward Z. Yang at 29/11/11 16:19 did gyre and gimble:
> Hello folks,
> 
> On this ticket [1], we're attempting to figure out what
> the relationship between services like httpd.service and remote-fs.target
> are.  One particular point of contention is this: what is the
> difference between 'After' and 'RequiredBy'? Which is correct
> in this circumstance?

I think RequiredBy is just the same semantically as Requires (it just
allows the requirement to be specified in a remote unit), in which case
this section from the manual page (man 5 systemd.unit) should explain
things. Ultimately Wants/Requires do not implicitly guide the ordering
of service start, but Before/After do. With Requires/Wants both services
might be started at the same time and thus one service needs the other
to be up and running while it starts up, you will need to add the
After/Before keys somewhere. It's worth reading the rest of the man
page, especially the section on Before= and After=.

HTHs



Requires=
    Configures requirement dependencies on other units. If this unit
    gets activated, the units listed here will be activated as well. If
    one of the other units gets deactivated or its activation fails,
    this unit will be deactivated. This option may be specified more
    than once, in which case requirement dependencies for all listed
    names are created. Note that requirement dependencies do not
    influence the order in which services are started or stopped. This
    has to be configured independently with the After= or Before=
    options. If a unit foo.service requires a unit bar.service as
    configured with Requires= and no ordering is configured with After=
    or Before=, then both units will be started simultaneously and
    without any delay between them if foo.service is activated. Often
    it is a better choice to use Wants= instead of Requires= in order
    to achieve a system that is more robust when dealing with failing
    services.


Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/



More information about the systemd-devel mailing list