CoreOS start service after another service has started

I have two services running in CoreOS, servicea and serviceb. When servicea starts and is ready, I need to run serviceb to run some commands against servicea.

What is the best way to tell systemd to start that serviceb when servicea starts? Trying to read through the systemd documentation and after trail and error has landed me right here :grinning:.

Here is an example fcct (or butane now?) YAML file:

variant: fcos
version: 1.3.0
systemd:
  units:
    - name: consul.service
      enabled: true
      contents: |
        [Unit]
        # unit stuff here
        [Service]
        ExecStart=/usr/local/bin/servicea
        [Install]
        WantedBy=serviceb.service
        RequiredBy=serviceb.service
    - name: serviceb.service
      enabled: false
      contents: |
        [Unit]
        Requires=servicea.service
        Wants=servicea.service
        [Service]
        Type=oneshot
        ExecStart=/usr/local/bin/serviceb.sh
        [Install]
        WantedBy=servicea.service
1 Like

Hi,

Have you tried using After= ?

[Unit]
After=servicea.service

Thanks Tom.

3 Likes

Thank you Tom, I completely read the order incorrectly!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.