That's a common issue with distributed systems.
Something has to be "the leader" and you need a system for choosing a new one once the old one is offline for a certain amount of time.
Add in a sprinkling of how to figure out if you have more than one leader active at a time.