I have a service A that runs in a limited number of environments to provision a host with some files. I have another service B that runs in all environments. I'd like B to depend on (and only start after) A if they are both running in the same environment.
I thought to simply add an After=A
and Requires=A
to B based on the answer here
After
only checks if the unit is activated already, and does not explicitly activate the specified units.- The units listed in
Requires
are activated together with the unit. If any of the required units fail to start, the unit is not activated.
which seems to indicate that both of these, After=
and Requires=
, are needed to ensure a dependency is started before this (B) unit.
But what happens if that specified unit doesn't exist, ie. in the environment where service A doesn't run? Is the dependency a no-op?