diff --git a/deploy.sh b/deploy.sh index 409f297..0e6a149 100755 --- a/deploy.sh +++ b/deploy.sh @@ -17,14 +17,47 @@ docker run --rm -v $(pwd):/app \ cd .. sh ./create_volumes.sh +# Keep the timestamp of when starting up containers +TIME_START=`date +%s` + # Run containers docker-compose -f docker-compose-jfrog.yml up --detach -# Wait until everything is up, 2 mins should be enough. -sleep 120 + +# loop until all containers are up +while 1; do + # if any container other than composer has exited, bail out + res=`docker ps -a | \ + grep "/curex-local/kea_" | \ + grep -v "kea_composer" | \ + grep "Exited" | \ + wc -l` + if [ $res -gt 0 ]; then + echo "ERROR: Some containers have exited." + docker ps -a | grep "/curex-local/kea_" + exit 1 + fi + # count containers that are up + res=`docker ps -a | \ + grep "/curex-local/kea_" | \ + grep -v "kea_composer" | \ + grep "Up" | \ + wc -l` + if [ $res -eq 11 ]; then + break + fi + # only wait for 10 mins until everything is up. It should be more than + # enough. + TIME_NOW=`date +%s` + if [ $((TIME_NOW - TIME_START)) -ge 600 ]; then + echo "ERROR: Timeout exceeded." + exit 2 + fi + sleep 1 +done + +# Wait a bit more +sleep 10 # create and populate the database docker-compose -f docker-compose-jfrog.yml exec api php artisan migrate:fresh --seed --force -#Check that everything is running succesfully -docker ps -a | grep "^CONTAINER\|/curex-local/kea_" -