We're using systemd to run various services in production. (Duh...)
We're building out a matching "disaster-recovery" site, which will have the same application installed -- with the same systemd-units to bring up its various components in case of a disaster.
This DR-environment is "hot", ready to take over within a short time (the shorter the better) -- thus becoming production itself. Then, when the "disaster" is resolved, the other environment is to become the DR.
My question is, how to keep those systemd-services ready-to-start, but not actually starting until a certain condition becomes true?
In order to conclude, that a particular site is currently the primary (production), a command (
amIthePrimary) needs to run and exit with a 0 exit-code. The check is easy and fast -- and can be performed as often as once a minute. But, because it requires running a command, there is no
Condition for it provided by systemd.
Do I put that command into every unit's
ExecPre, or will that become a noisy error, needlessly annoying the administrators? Do I put it into a unit of its own, with all other services
Separately, once the condition is true -- and the services start -- how do I continue checking it, so they will all shut down, should it become false again?