| ... | ... |
@@ -78,25 +78,36 @@ func main() {
|
| 78 | 78 |
if err != nil {
|
| 79 | 79 |
log.Fatal(err) |
| 80 | 80 |
} |
| 81 |
- // Load plugin: httpapi |
|
| 82 |
- job := eng.Job("initserver")
|
|
| 83 |
- job.Setenv("Pidfile", *pidfile)
|
|
| 84 |
- job.Setenv("Root", *flRoot)
|
|
| 85 |
- job.SetenvBool("AutoRestart", *flAutoRestart)
|
|
| 86 |
- job.SetenvList("Dns", flDns.GetAll())
|
|
| 87 |
- job.SetenvBool("EnableIptables", *flEnableIptables)
|
|
| 88 |
- job.SetenvBool("EnableIpForward", *flEnableIpForward)
|
|
| 89 |
- job.Setenv("BridgeIface", *bridgeName)
|
|
| 90 |
- job.Setenv("BridgeIP", *bridgeIp)
|
|
| 91 |
- job.Setenv("DefaultIp", *flDefaultIp)
|
|
| 92 |
- job.SetenvBool("InterContainerCommunication", *flInterContainerComm)
|
|
| 93 |
- job.Setenv("GraphDriver", *flGraphDriver)
|
|
| 94 |
- job.SetenvInt("Mtu", *flMtu)
|
|
| 95 |
- if err := job.Run(); err != nil {
|
|
| 96 |
- log.Fatal(err) |
|
| 97 |
- } |
|
| 81 |
+ // load the daemon in the background so we can immediately start |
|
| 82 |
+ // the http api so that connections don't fail while the daemon |
|
| 83 |
+ // is booting |
|
| 84 |
+ go func() {
|
|
| 85 |
+ // Load plugin: httpapi |
|
| 86 |
+ job := eng.Job("initserver")
|
|
| 87 |
+ job.Setenv("Pidfile", *pidfile)
|
|
| 88 |
+ job.Setenv("Root", *flRoot)
|
|
| 89 |
+ job.SetenvBool("AutoRestart", *flAutoRestart)
|
|
| 90 |
+ job.SetenvList("Dns", flDns.GetAll())
|
|
| 91 |
+ job.SetenvBool("EnableIptables", *flEnableIptables)
|
|
| 92 |
+ job.SetenvBool("EnableIpForward", *flEnableIpForward)
|
|
| 93 |
+ job.Setenv("BridgeIface", *bridgeName)
|
|
| 94 |
+ job.Setenv("BridgeIP", *bridgeIp)
|
|
| 95 |
+ job.Setenv("DefaultIp", *flDefaultIp)
|
|
| 96 |
+ job.SetenvBool("InterContainerCommunication", *flInterContainerComm)
|
|
| 97 |
+ job.Setenv("GraphDriver", *flGraphDriver)
|
|
| 98 |
+ job.SetenvInt("Mtu", *flMtu)
|
|
| 99 |
+ if err := job.Run(); err != nil {
|
|
| 100 |
+ log.Fatal(err) |
|
| 101 |
+ } |
|
| 102 |
+ // after the daemon is done setting up we can tell the api to start |
|
| 103 |
+ // accepting connections |
|
| 104 |
+ if err := eng.Job("acceptconnections").Run(); err != nil {
|
|
| 105 |
+ log.Fatal(err) |
|
| 106 |
+ } |
|
| 107 |
+ }() |
|
| 108 |
+ |
|
| 98 | 109 |
// Serve api |
| 99 |
- job = eng.Job("serveapi", flHosts.GetAll()...)
|
|
| 110 |
+ job := eng.Job("serveapi", flHosts.GetAll()...)
|
|
| 100 | 111 |
job.SetenvBool("Logging", true)
|
| 101 | 112 |
job.SetenvBool("EnableCors", *flEnableCors)
|
| 102 | 113 |
job.Setenv("Version", dockerversion.VERSION)
|
| ... | ... |
@@ -171,9 +171,14 @@ func spawnGlobalDaemon() {
|
| 171 | 171 |
log.Fatalf("Unable to spawn the test daemon: %s", err)
|
| 172 | 172 |
} |
| 173 | 173 |
}() |
| 174 |
+ |
|
| 174 | 175 |
// Give some time to ListenAndServer to actually start |
| 175 | 176 |
// FIXME: use inmem transports instead of tcp |
| 176 | 177 |
time.Sleep(time.Second) |
| 178 |
+ |
|
| 179 |
+ if err := eng.Job("acceptconnections").Run(); err != nil {
|
|
| 180 |
+ log.Fatalf("Unable to accept connections for test api: %s", err)
|
|
| 181 |
+ } |
|
| 177 | 182 |
} |
| 178 | 183 |
|
| 179 | 184 |
// FIXME: test that ImagePull(json=true) send correct json output |