In fact, you can let the supervisor immediately restart its children and implement the so-called lazy initialization:
- The supervisor (re) runs (immediately) a child (say gen_server)
- gen_server returns timeout 0 in its init function
- In handle_info, you activate the wait (10 seconds) to ensure that the DB is properly initialized.
Thus, you guarantee that all requests to gen_server are processed after the database is correctly initialized.
Roberto aloi
source share