How to configure systemd?

Help to configure dependencies in systemd. We need to organize two services according to the following algorithm:
1. The first service is started before the second, even if launched first second service
2. If one service is stopped, then the other must also stop
3. If one of the services fell, the second one should stay with the status failed.

As I understand it, you need to use Requires, After, Before. Then you can control the launch sequence. But I can not make so that if one service suddenly fell, then the second service is also falling.

********************************
# Service1
[Unit]
Requires=service2.service
Before=service2.service
********************************
#Service2
[Unit]
Requires=service1.service
After=service1.service


Found the BindsTo parameter, which causes the service to stop if the other fell. But the truth is the service in this case has an inactive status, not failed as we would like.
June 5th 19 at 21:45
2 answers
June 5th 19 at 21:47
Solution
According to claim 2,3 I think this will do:
BindsTo=
Configures requirement dependencies, very similar in style to Requires=. However, this dependency type is stronger: in addition to the effect of the Requires= it declares that if the unit bound to is stopped, this unit will be stopped too. This means a unit bound to another unit that suddenly enters inactive state will be stopped too...

Read more man systemd.unit
Well, not quite what you need, because if one of the services crashes, the second also stopped, but the status is inactive, and I would like to with a status of failed - Benjamin.Keebler commented on June 5th 19 at 21:50
if one of the services has fallen it will have a status of failed, and the second because of the fallen of the first adequately braked, then with the second everything is fine and he just is inactive.
All true and logical. any unnecessary problems.

And you just need to track the status of both services. - Sandra_Kautzer42 commented on June 5th 19 at 21:53
well yeah, I guess it will have to do - Benjamin.Keebler commented on June 5th 19 at 21:56
and we need to do.
to finish the unification of the two conditions in the script and everything is OK.

And hitroopye designs usually come out sideways. - Sandra_Kautzer42 commented on June 5th 19 at 21:59
thanks for the tip - Benjamin.Keebler commented on June 5th 19 at 22:02
June 5th 19 at 21:49
It is easier to combine the 2 services in 1.
What makes you think it is easier? - Benjamin.Keebler commented on June 5th 19 at 21:52

Find more questions by tags UbuntuLinux