<div dir="ltr"><div>Hello,</div><div><br></div><div>I have a question about service dependencies.<br><br>Assume there are two services<br>* test1<br>* test2<br><br>(for testing purpose only I am using user services)<br><br>The test2 service requires that test1 service is active.<br>The test2 service cannot work if test1 is not active, so it should ensure<br>* test1 is started before test2<br>* test2 is terminated if test1 terminates<br><br>I tried this unit section for test2.service<br><br>BindsTo=test1.service<br>After=test1.service<br><br>(The point I do not understand is equal for `Requires` instead of `BindsTo`)<br><br>If I start test2.service test1 is started and afterwards test2.<br><br>systemctl --user start test2<br><br>Jan 10 11:46:59 tpt590 systemd[2552]: Started test1.service.<br>Jan 10 11:46:59 tpt590 systemd[2552]: Started test2.service.<br><br>If I stop test1.service teset2 is stopped, too.<br><br>systemctl --user stop test1<br><br>Jan 10 11:47:49 tpt590 systemd[2552]: Stopping test2.service...<br>Jan 10 11:47:49 tpt590 systemd[2552]: Stopped test2.service.<br>Jan 10 11:47:49 tpt590 systemd[2552]: Stopping test1.service...<br>Jan 10 11:47:49 tpt590 systemd[2552]: Stopped test1.service.<br><br>Then I start test1.service again<br><br>systemctl --user start test1<br><br>Jan 10 11:48:42 tpt590 systemd[2552]: Started test1.service.<br><br>What I do not understand is, why `test2.service` is not started again.<br>Or how can I ensure test2 is started again?<br><br>* test2 requires / binds to test1<br>* test2 has been started explicit<br>* test1 is started as a dependency<br>* the dependency test1 is stopped explicit<br>*
I would assume the service manager still is aware of the explicit start
of test2 but stopped it because the requirements / dependencies does
not met.<br>* I would assume if test1 (the missing requirement /
dependency) is started again the service manager realize that now all
dependencies are met and test2 can be started again, too.<br><br>Why is this wrong?<br>How can I declare test2 unit section to ensure it works as expected by me?</div><div><br></div><div>Many thanks in advance,</div><div>Markus</div></div>