From 567e8a05995d976c52a5e627ebd82defdaa1300b Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Tue, 14 May 2013 08:39:25 -0700 Subject: [PATCH] Avoid race condition with 1 second sleep. Upstart will return from 'start xxx' immediately upon forking. We still need to run start-stop-daemon, change users, exec again, and then run the python code to get to listen() before the service is actually ready. This all should take < 1s, but the sleep is just a stopgap until we have a better way to track "is the service ready" in upstart. Fixes bug #1179766 Change-Id: I3842e572c940e833cb3036b67df0ee71fe5bb129 --- elements/os-svc-install/bin/os-svc-daemon | 3 +++ 1 file changed, 3 insertions(+) diff --git a/elements/os-svc-install/bin/os-svc-daemon b/elements/os-svc-install/bin/os-svc-daemon index 969b3c670..c8b9edd21 100755 --- a/elements/os-svc-install/bin/os-svc-daemon +++ b/elements/os-svc-install/bin/os-svc-daemon @@ -20,6 +20,9 @@ end script respawn exec start-stop-daemon --start -c $user --exec /opt/stack/venvs/$user/bin/$cmd -- $args + +# Help avoid race with daemon listening. http://pad.lv/1179766 +post-start exec sleep 1 EOF }