remote: Add a Ready method to know when startup is finished
Previously, there was an extremely rare race where we would startup, kick off the Run method in a goroutine, and then run Exit before Run got very far in its execution. If Run ran some early sections of its code _after_ we had Exited, we would trigger a panic due to the converger UID being unregistered. This patch blocks Exit from progressing until Run has started and finished running. It also adds a Ready method so that you can monitor this signal yourself if you'd like to add the necessary wait to your code.
This commit is contained in:
@@ -629,6 +629,14 @@ func (obj *Main) Run() error {
|
||||
// TODO: is there any benefit to running the remotes above in the loop?
|
||||
// wait for etcd to be running before we remote in, which we do above!
|
||||
go remotes.Run()
|
||||
// wait for remotes to be ready before continuing...
|
||||
select {
|
||||
case <-remotes.Ready():
|
||||
log.Printf("Main: Remotes: Run: Ready!")
|
||||
// pass
|
||||
//case <-time.After( ? * time.Second):
|
||||
// obj.Exit(fmt.Errorf("Main: Remotes: Run timeout"))
|
||||
}
|
||||
|
||||
if obj.GAPI == nil {
|
||||
converger.Start() // better start this for empty graphs
|
||||
|
||||
Reference in New Issue
Block a user