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

Integration generic socket wait for docker api

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-02-15 20:49:50 -08:00
parent 64716a21e4
commit 778f1bf663
3 changed files with 34 additions and 20 deletions

View file

@ -1219,8 +1219,6 @@ func ServeApi(job *engine.Job) engine.Status {
}() }()
} }
AcceptConnections(nil)
for i := 0; i < len(protoAddrs); i += 1 { for i := 0; i < len(protoAddrs); i += 1 {
err := <-chErrors err := <-chErrors
if err != nil { if err != nil {

View file

@ -78,25 +78,36 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
// Load plugin: httpapi // load the daemon in the background so we can immediately start
job := eng.Job("initserver") // the http api so that connections don't fail while the daemon
job.Setenv("Pidfile", *pidfile) // is booting
job.Setenv("Root", *flRoot) go func() {
job.SetenvBool("AutoRestart", *flAutoRestart) // Load plugin: httpapi
job.SetenvList("Dns", flDns.GetAll()) job := eng.Job("initserver")
job.SetenvBool("EnableIptables", *flEnableIptables) job.Setenv("Pidfile", *pidfile)
job.SetenvBool("EnableIpForward", *flEnableIpForward) job.Setenv("Root", *flRoot)
job.Setenv("BridgeIface", *bridgeName) job.SetenvBool("AutoRestart", *flAutoRestart)
job.Setenv("BridgeIP", *bridgeIp) job.SetenvList("Dns", flDns.GetAll())
job.Setenv("DefaultIp", *flDefaultIp) job.SetenvBool("EnableIptables", *flEnableIptables)
job.SetenvBool("InterContainerCommunication", *flInterContainerComm) job.SetenvBool("EnableIpForward", *flEnableIpForward)
job.Setenv("GraphDriver", *flGraphDriver) job.Setenv("BridgeIface", *bridgeName)
job.SetenvInt("Mtu", *flMtu) job.Setenv("BridgeIP", *bridgeIp)
if err := job.Run(); err != nil { job.Setenv("DefaultIp", *flDefaultIp)
log.Fatal(err) job.SetenvBool("InterContainerCommunication", *flInterContainerComm)
} job.Setenv("GraphDriver", *flGraphDriver)
job.SetenvInt("Mtu", *flMtu)
if err := job.Run(); err != nil {
log.Fatal(err)
}
// after the daemon is done setting up we can tell the api to start
// accepting connections
if err := eng.Job("acceptconnections").Run(); err != nil {
log.Fatal(err)
}
}()
// Serve api // Serve api
job = eng.Job("serveapi", flHosts.GetAll()...) job := eng.Job("serveapi", flHosts.GetAll()...)
job.SetenvBool("Logging", true) job.SetenvBool("Logging", true)
job.SetenvBool("EnableCors", *flEnableCors) job.SetenvBool("EnableCors", *flEnableCors)
job.Setenv("Version", dockerversion.VERSION) job.Setenv("Version", dockerversion.VERSION)

View file

@ -171,9 +171,14 @@ func spawnGlobalDaemon() {
log.Fatalf("Unable to spawn the test daemon: %s", err) log.Fatalf("Unable to spawn the test daemon: %s", err)
} }
}() }()
// Give some time to ListenAndServer to actually start // Give some time to ListenAndServer to actually start
// FIXME: use inmem transports instead of tcp // FIXME: use inmem transports instead of tcp
time.Sleep(time.Second) time.Sleep(time.Second)
if err := eng.Job("acceptconnections").Run(); err != nil {
log.Fatalf("Unable to accept connections for test api: %s", err)
}
} }
// FIXME: test that ImagePull(json=true) send correct json output // FIXME: test that ImagePull(json=true) send correct json output