Skip to content
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

Merged
merged 1 commit into from
Aug 23, 2015
Merged

Notify when daemon is ready #1569

merged 1 commit into from
Aug 23, 2015

Conversation

rht
Copy link
Contributor

@rht rht commented Aug 13, 2015

Fixes #752

@jbenet jbenet added the status/in-progress In progress label Aug 13, 2015
License: MIT
Signed-off-by: rht <[email protected]>
@rht
Copy link
Contributor Author

rht commented Aug 13, 2015

For #862, one way is to reuse daemonFunc in cmd/ipfs/daemon.go, add

//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")
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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!")
}()

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sounds good

@jbenet jbenet mentioned this pull request Aug 22, 2015
16 tasks
jbenet added a commit that referenced this pull request Aug 23, 2015
Notify when daemon is ready
@jbenet jbenet merged commit a052087 into ipfs:master Aug 23, 2015
@jbenet jbenet removed the status/in-progress In progress label Aug 23, 2015
@rht rht deleted the daemon-msg branch August 23, 2015 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants