Commit 1898c47f2a9f7e44215a2f3a6c78b0855d96b576
1 parent
3f6bad8ffd
Exists in
master
and in
4 other branches
Loop until all all containers are up
Showing 1 changed file with 38 additions and 5 deletions
deploy.sh
View file @
1898c47
... | ... | @@ -17,14 +17,47 @@ |
17 | 17 | cd .. |
18 | 18 | sh ./create_volumes.sh |
19 | 19 | |
20 | +# Keep the timestamp of when starting up containers | |
21 | +TIME_START=`date +%s` | |
22 | + | |
20 | 23 | # Run containers |
21 | 24 | docker-compose -f docker-compose-jfrog.yml up --detach |
22 | -# Wait until everything is up, 2 mins should be enough. | |
23 | -sleep 120 | |
24 | 25 | |
26 | +# loop until all containers are up | |
27 | +while 1; do | |
28 | + # if any container other than composer has exited, bail out | |
29 | + res=`docker ps -a | \ | |
30 | + grep "/curex-local/kea_" | \ | |
31 | + grep -v "kea_composer" | \ | |
32 | + grep "Exited" | \ | |
33 | + wc -l` | |
34 | + if [ $res -gt 0 ]; then | |
35 | + echo "ERROR: Some containers have exited." | |
36 | + docker ps -a | grep "/curex-local/kea_" | |
37 | + exit 1 | |
38 | + fi | |
39 | + # count containers that are up | |
40 | + res=`docker ps -a | \ | |
41 | + grep "/curex-local/kea_" | \ | |
42 | + grep -v "kea_composer" | \ | |
43 | + grep "Up" | \ | |
44 | + wc -l` | |
45 | + if [ $res -eq 11 ]; then | |
46 | + break | |
47 | + fi | |
48 | + # only wait for 10 mins until everything is up. It should be more than | |
49 | + # enough. | |
50 | + TIME_NOW=`date +%s` | |
51 | + if [ $((TIME_NOW - TIME_START)) -ge 600 ]; then | |
52 | + echo "ERROR: Timeout exceeded." | |
53 | + exit 2 | |
54 | + fi | |
55 | + sleep 1 | |
56 | +done | |
57 | + | |
58 | +# Wait a bit more | |
59 | +sleep 10 | |
60 | + | |
25 | 61 | # create and populate the database |
26 | 62 | docker-compose -f docker-compose-jfrog.yml exec api php artisan migrate:fresh --seed --force |
27 | - | |
28 | -#Check that everything is running succesfully | |
29 | -docker ps -a | grep "^CONTAINER\|/curex-local/kea_" |