I have two runtime services running on my linux machine. I have it setup so that apt-get update and apt-get upgrade updates the services, in case I've pushed an update to either one.
Now my problem is, that A.service makes an API call to B.service during initialization to retrieve system information. (A.service does stuff, B.service fetches information and exposes the information in form of an API for A.service).
After updating, I have to restart both services, to do so I'm executing 'sudo systemctl restart A.service B.service'. Now A.service fails to initialize because B.Service isn't running yet.
A.service configuration file:
[Unit]
Description=A.service
After=B.service
Requires=B.service
[Service]
Type=notify
NotifyAccess=all
ExecStart=/usr/bin/a_service
B.service configuration file:
[Unit]
Description=B.service
Before=A.service
[Service]
Type=notify
NotifyAccess=all
ExecStart=/usr/bin/b_service
To my understanding, 'After' and 'Before' should define the startup order. This works fine when rebooting the machine, but I have to make this work with restart as well, because rebooting after every update isn't feasible.
Desired Outcome:
$ sudo systemctl restart A.service B.service
...
Started B.service
Started A.service
...
Is there any way to achieve this? Currently when executing 'systemctl restart A.service B.service, A will start before B and therefore exit with a failure.