Browse code

move acceptconnections as builtin

Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)

Victor Vieux authored on 2014/05/03 09:11:20
Showing 3 changed files
... ...
@@ -1285,10 +1285,6 @@ func ServeApi(job *engine.Job) engine.Status {
1285 1285
 	)
1286 1286
 	activationLock = make(chan struct{})
1287 1287
 
1288
-	if err := job.Eng.Register("acceptconnections", AcceptConnections); err != nil {
1289
-		return job.Error(err)
1290
-	}
1291
-
1292 1288
 	for _, protoAddr := range protoAddrs {
1293 1289
 		protoAddrParts := strings.SplitN(protoAddr, "://", 2)
1294 1290
 		if len(protoAddrParts) != 2 {
... ...
@@ -1315,7 +1311,9 @@ func AcceptConnections(job *engine.Job) engine.Status {
1315 1315
 	go systemd.SdNotify("READY=1")
1316 1316
 
1317 1317
 	// close the lock so the listeners start accepting connections
1318
-	close(activationLock)
1318
+	if activationLock != nil {
1319
+		close(activationLock)
1320
+	}
1319 1321
 
1320 1322
 	return engine.StatusOK
1321 1323
 }
... ...
@@ -28,7 +28,10 @@ func Register(eng *engine.Engine) error {
28 28
 
29 29
 // remote: a RESTful api for cross-docker communication
30 30
 func remote(eng *engine.Engine) error {
31
-	return eng.Register("serveapi", apiserver.ServeApi)
31
+	if err := eng.Register("serveapi", apiserver.ServeApi); err != nil {
32
+		return err
33
+	}
34
+	return eng.Register("acceptconnections", apiserver.AcceptConnections)
32 35
 }
33 36
 
34 37
 // daemon: a default execution and storage backend for Docker on Linux,
... ...
@@ -185,7 +185,7 @@ func main() {
185 185
 		job.Setenv("TlsCa", *flCa)
186 186
 		job.Setenv("TlsCert", *flCert)
187 187
 		job.Setenv("TlsKey", *flKey)
188
-		job.SetenvBool("BuffferRequests", true)
188
+		job.SetenvBool("BufferRequests", true)
189 189
 		if err := job.Run(); err != nil {
190 190
 			log.Fatal(err)
191 191
 		}