Actually, you could let the supervisor to immediately restart its children and implement what is called lazy initialization:
The supervisor (re)starts (immediately) the child (say, a gen_server)
The gen_server returns a 0 timeout in its init function
In the handle_info you do an active wait (your 10 seconds) to ensure the DB is properly initialized This way, you ensure that all requests to the gen_server are processed after the DB is properly initialized.
1条答案
按热度按时间gzjq41n41#
Actually, you could let the supervisor to immediately restart its children and implement what is called lazy initialization:
This way, you ensure that all requests to the gen_server are processed after the DB is properly initialized.