title: Systemd: Using both After and Requires
body: <p>I have a service <code>foo.service</code> which depends on service <code>bar.service</code>. I need to make sure that <code>bar.service</code> is started before <code>foo.service</code> and that <code>bar.service</code> launched successfully.</p>
  
  <p>From <a href="https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files" rel="noreferrer">this source</a> it says that <code>Requires</code>:</p>
  
  <blockquote>
    <p>This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.</p>
  </blockquote>
  
  <p>and that <code>After</code>:</p>
  
  <blockquote>
    <p>The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.</p>
  </blockquote>
  
  <p>Is it correct to have both the <code>Requires</code> and <code>After</code> sections in the same unit file? <code>Requires</code> says that the service will be launched in parallel, but <code>After</code> says it will be launched before. If <code>bar.service</code> fails to start during the <code>After</code> condition, will it attempt to launch it again during the <code>Requires</code> section? If so I need to find another way to launch <code>foo.service</code></p>
  
  <p><code>foo.service</code></p>
  
  <pre><code>[Unit]
  After=bar.service
  Requires=bar.service
  </code></pre>