But it leans on using sleep methods for replicaset setup, which I find little hackish/unreliable. I would have thought that somebody would have more sophisticated method after 5 years.
Same applies to another repo:
Or little bit never version (which probably eliminates sleeps by doing something else meanwhile)
Googling finds nothing conclusive in this case. However, you can check replica set status with rs.status(). I believe something must appear in its output once the initialization is complete, so you can poll that.
Alternatively, something probably appears in the MongoDB server’s log once each of those operations is complete – so you can watch that instead. Although in this case, you’ll be relying on the set and content of log messages – which is probably undocumented and subject to change without notice and between versions as well as dependent on server settings.