From 90506274df7b410752f0a29027a4d1a0d15b8128 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 12 Dec 2013 16:53:02 -0800 Subject: [PATCH] cid recovery code for invalid cids and such --- launcher | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/launcher b/launcher index 84b22c8..5755940 100755 --- a/launcher +++ b/launcher @@ -197,11 +197,36 @@ case "$command" in set_template_info set_volumes + existing=`docker ps -a | awk '{ print $1, $(NF) }' | grep $config | awk '{ print $1 }'` + if [ ! -z $existing ] + then + echo "Found an existing container by its name, recovering cidfile, please rerun" + echo $existing > $cidfile + exit 1 + fi + docker run $env -e DOCKER_HOST_IP=$docker_ip -name $config -cidfile $cidfile $ports \ -d $volumes $local_discourse/$config /usr/bin/runsvdir -P /etc/service exit 0 else + cid=`cat $cidfile` + + if [ -z $cid ] + then + echo "Detected empty cid file, deleting, please re-run" + rm $cidfile + exit 1 + fi + + found=`docker ps -q -a | grep $cid` + if [ -z $found ] + then + echo "Invalid cid file, deleting, please re-run" + rm $cidfile + exit 1 + fi + echo "cid found, ensuring container is started" docker start `cat $cidfile` exit 0 -- 2.25.1