1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Revert "Return listenbuffer behavior"

This reverts commit 281a48d092.

Signed-off-by: Alex Crawford <alex.crawford@coreos.com>
This commit is contained in:
Alex Crawford 2015-11-24 18:17:37 -08:00
parent 900c8f5847
commit a8b84cd8fb
2 changed files with 15 additions and 21 deletions

View file

@ -78,10 +78,11 @@ func (s *Server) Close() {
}
// ServeAPI loops through all initialized servers and spawns goroutine
// with Serve() method for each.
// with Server method for each. It sets CreateMux() as Handler also.
func (s *Server) ServeAPI() error {
var chErrors = make(chan error, len(s.servers))
for _, srv := range s.servers {
srv.srv.Handler = s.CreateMux()
go func(srv *HTTPServer) {
var err error
logrus.Infof("API listen on %s", srv.l.Addr())
@ -168,16 +169,11 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc {
}
// InitRouters initializes a list of routers for the server.
// Sets those routers as Handler for each server.
func (s *Server) InitRouters(d *daemon.Daemon) {
s.addRouter(local.NewRouter(d))
s.addRouter(network.NewRouter(d))
s.addRouter(volume.NewRouter(d))
s.addRouter(container.NewRouter(d))
for _, srv := range s.servers {
srv.srv.Handler = s.CreateMux()
}
}
// addRouter adds a new router to the server.

View file

@ -217,21 +217,6 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error {
logrus.Fatal(err)
}
// The serve API routine never exits unless an error occurs
// We need to start it as a goroutine and wait on it so
// daemon doesn't exit
// All servers must be protected with some mechanism (systemd socket, listenbuffer)
// which prevents real handling of request until routes will be set.
serveAPIWait := make(chan error)
go func() {
if err := api.ServeAPI(); err != nil {
logrus.Errorf("ServeAPI error: %v", err)
serveAPIWait <- err
return
}
serveAPIWait <- nil
}()
if err := migrateKey(); err != nil {
logrus.Fatal(err)
}
@ -259,6 +244,19 @@ func (cli *DaemonCli) CmdDaemon(args ...string) error {
api.InitRouters(d)
// The serve API routine never exits unless an error occurs
// We need to start it as a goroutine and wait on it so
// daemon doesn't exit
serveAPIWait := make(chan error)
go func() {
if err := api.ServeAPI(); err != nil {
logrus.Errorf("ServeAPI error: %v", err)
serveAPIWait <- err
return
}
serveAPIWait <- nil
}()
signal.Trap(func() {
api.Close()
<-serveAPIWait