Context
I want A.service to be started only after B.service finishes starting up, and B.service is a unit that's activated by the corresponding systemd path unit: B.path. Relevant code snippets can be found below.
A.service:
[Unit]
After=B.service
B.path:
[Path]
PathExists=/some/path
[Install]
RequiredBy=A.service
Problem
During bootup, I can see that A.service does activate B.path, and then B.service is activated after /some/path is there, but the problem is that A.service still starts before B.service finishes starting up. From checking the journald logs, the timeline looks like this:
T0:A.serviceis started (and then failed coz its setup depends onB.service)B.pathis started
T0+Xseconds:B.serviceis started
X is somewhere between 3~6 depending on when the path comes into existence during bootup.
Documentation
I checked the systemd documentation for Before=, After= (link) and found this:
If unit foo.service contains the setting Before=bar.service and both units are being started
This makes me wonder if it's because of the both units are being started bit. To be specific, B.service was only being started after /some/path is there, which can be X seconds after A.service was being started.
However, I'm not sure if my understanding of the documentation is correct, or I am actually missing something else. Either way, any recommendation to write the unit files to achieve what I want is appreciated. Thanks!