Make API server datastructure

Added daemon field to it, will use it later for acces to daemon from
handlers

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: d9ed3165228b60cb89c31d0d66b99e01ab83eb3e
Component: engine
This commit is contained in:
Alexander Morozov
2015-04-17 14:32:18 -07:00
parent 932b7d41ce
commit 2e27fa9e39
8 changed files with 131 additions and 105 deletions

View File

@ -105,12 +105,14 @@ func mainDaemon() {
TlsKey: *flKey,
}
api := apiserver.New(serverConfig, eng)
// 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 := apiserver.ServeApi(flHosts, serverConfig, eng); err != nil {
if err := api.ServeApi(flHosts); err != nil {
logrus.Errorf("ServeAPI error: %v", err)
serveAPIWait <- err
return
@ -143,8 +145,8 @@ func mainDaemon() {
b.Install()
// after the daemon is done setting up we can tell the api to start
// accepting connections
apiserver.AcceptConnections()
// accepting connections with specified daemon
api.AcceptConnections(d)
// Daemon is fully initialized and handling API traffic
// Wait for serve API job to complete