-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notify when daemon is ready #1569
Conversation
License: MIT Signed-off-by: rht <[email protected]>
For #862, one way is to reuse //early on
readyErrc := make(chan error)
res.SetOutput(readyErrc)
...
//after the "Daemon is ready" message
readyErrc <- nil To use this in other place daemonExit := make(chan error)
go func(){
daemonFunc(req, res)
daemonExit <- res.Error()
}()
for {
select {
case <-res.Output():
// daemon is ready
case <-daemonExit:
// daemon exit
break
}
} |
@@ -274,6 +274,7 @@ func daemonFunc(req cmds.Request, res cmds.Response) { | |||
} | |||
} | |||
|
|||
fmt.Printf("Daemon is ready\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be the last thing printed even in light of scheduler fun, or slow-to-start HTTP servers and so on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, likely not. Need to check the ports of each server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as long as it's the last thing printed, it can be ok. servers dont have to be checked explicitly. maybe we can do this with a wait group? (add N to the wait group, and do wg.Done()
as the lines are printed. the last one is:
go func () {
wg.Wait()
fmt.Println("Daemon is ready!")
}()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message will surely print last among the other server messages.
However, each of the messages, e.g. fmt.Printf("Gateway (writable) server listening on %s\n", gatewayMaddr)
prints before each server runs.
If this is ok (servers don't have to be running, as long as the daemon ready msg prints last), then the pr is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sounds good
Fixes #752