Sample Header Ad - 728x90

Do not stop the service if required service exits?

0 votes
0 answers
51 views
I have the following scenario that I'm trying to implement: - service b requires service a so that when b starts it forces a to start successfully (or still be active) or fails if a fails - service a is oneshot that has to stay active for a minute and then stop, currently done with ExecStartPost=systemd-run --on-active=60 systemctl stop zz The problem is that when a gets stopped it drags b with it. Is there a way to implement the dependency in such a way that initially b checks if a is successful or not and continues depending on the result, however later b shouldn't care about the status of a. Unless b is restarted, then it needs a to either still be active or start it again. The reason for such a scenario is that a checks if a remote server is reachable. And there is more than one service like b that connects to this remote service. So the goal is to avoid doing same checks multiple times within a short time window (these services are started on multiple servers so the amount of checks could get into ddos territory). I could implement it with state/flag files but ideally it would be nice to avoid creating extra entities if there is a way to implement it just with systemd services.
Asked by Phoenix (101 rep)
Jan 18, 2025, 06:05 PM