From d9902b0a95989296913b985f7ba1407011e20226 Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Fri, 28 Feb 2014 20:43:08 -0800 Subject: [PATCH] fix(api): serve until the "acceptconnections" job This fixes a bug that I encountered when using socket activation with docker 0.8.1. When running the first `docker run` it would return: "create: command not found". The root cause was the socket activation code path was starting to listen before the "initserver" job had finished. This meant that the "create" handler hand't been registered yet leading to the command not found error. In log format it looks like this: ``` [/var/lib/docker|9d2e78e9] +job initserver() 2014/03/01 04:05:35 Listening for HTTP on fd () [/var/lib/docker|0d71c177] +job create() create: command not found [/var/lib/docker|0d71c177] -job create() [/var/lib/docker|0d71c177] +job acceptconnections() [/var/lib/docker|0d71c177] -job initserver() = OK (0) ``` To fix the issue select on the activationLock and block until the "acceptconnections" job has ran. Docker-DCO-1.1-Signed-off-by: Brandon Philips (github: philips) Upstream-commit: 8d2226b7e5a5d5334f80d3ec03313fe2cd3210a3 Component: engine --- components/engine/api/server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/engine/api/server.go b/components/engine/api/server.go index b6beb45403..7868600314 100644 --- a/components/engine/api/server.go +++ b/components/engine/api/server.go @@ -1079,6 +1079,11 @@ func ServeFd(addr string, handle http.Handler) error { chErrors := make(chan error, len(ls)) + // We don't want to start serving on these sockets until the + // "initserver" job has completed. Otherwise required handlers + // won't be ready. + <-activationLock + // Since ListenFD will return one or more sockets we have // to create a go func to spawn off multiple serves for i := range ls {