From: Sam Saffron Date: Fri, 13 Dec 2013 00:53:02 +0000 (-0800) Subject: cid recovery code for invalid cids and such X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=90506274df7b410752f0a29027a4d1a0d15b8128;p=discourse_docker.git cid recovery code for invalid cids and such --- 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