forked from FIWARE/NGSI-LD_TestSuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservices
executable file
·97 lines (90 loc) · 3.59 KB
/
services
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#
# Command Line Interface to start all services associated with the Getting-Started Tutorial
#
# For this tutorial the commands are merely a convenience script to run docker-compose
#
set -e
if (( $# != 1 )); then
echo "Illegal number of parameters"
echo "usage: services [create|start|stop]"
exit 1
fi
waitForOrion () {
echo -e "\n⏳ Waiting for \033[1;34mOrion\033[0m to be available\n"
while [ `docker run --network fiware_default --rm appropriate/curl -s -o /dev/null -w %{http_code} 'http://orion:1026/version'` -eq 000 ]
do
echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:1026/version'` " (waiting for 200)"
sleep 1
done
}
waitForScorpio () {
echo -e "\n⏳ Waiting for \033[1;34mScorpio\033[0m to become responsive\n"
while [ `docker run --network fiware_default --rm appropriate/curl -s -o /dev/null -w %{http_code} 'http://scorpio:9090/scorpio/v1/info/'` -eq 000 ]
do
echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:9090/scorpio/v1/info/'` " (waiting for 500)"
sleep 30
done
echo -e "\n⏳ Waiting for all \033[1;34mScorpio\033[0m services to be available\n"
while [ `docker run --network fiware_default --rm appropriate/curl -s -o /dev/null -w %{http_code} 'http://scorpio:9090/scorpio/v1/info/'` -eq 500 ]
do
echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:9090/scorpio/v1/info/'` " (waiting for 200)"
sleep 30
done
}
stoppingContainers () {
echo "Stopping containers"
docker-compose --log-level ERROR -f docker-compose/orion.yml -p fiware down -v --remove-orphans
docker-compose --log-level ERROR -f docker-compose/scorpio-aaio.yml -p fiware down -v --remove-orphans
docker-compose --log-level ERROR -f docker-compose/scorpio-dist.yml -p fiware down -v --remove-orphans
}
displayServices () {
echo ""
sleep 1
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" --filter name=$1-*
echo ""
}
command="$1"
case "${command}" in
"help")
echo "usage: services [create|orion|scorpio|scorpio-dist|stop]"
;;
"orion")
stoppingContainers
echo -e "Starting two containers \033[1;34mOrion\033[0m and a \033[1mMongoDB\033[0m database."
echo -e "- \033[1;34mOrion\033[0m is the context broker\n"
docker-compose --log-level ERROR -f docker-compose/orion.yml -p fiware up -d --remove-orphans
displayServices fiware
waitForOrion
;;
"scorpio")
stoppingContainers
echo -e "Starting four containers \033[1;34mScorpio\033[0m, \033[1mKafka\033[0m, \033[1mZookeeper\033[0m and a \033[1mPostgres\033[0m database."
echo -e "- \033[1;34mScorpio\033[0m is the context broker\n"
docker-compose --log-level ERROR -f docker-compose/scorpio-aaio.yml -p fiware up -d --remove-orphans
displayServices scorpio
waitForScorpio
;;
"scorpio-dist")
stoppingContainers
echo -e "Starting four containers \033[1;34mScorpio\033[0m, \033[1mKafka\033[0m, \033[1mZookeeper\033[0m and a \033[1mPostgres\033[0m database."
echo -e "- \033[1;34mScorpio\033[0m is the context broker\n"
docker-compose --log-level ERROR -f docker-compose/scorpio-dist.yml -p fiware up -d --remove-orphans
displayServices scorpio
waitForScorpio
;;
"stop")
stoppingContainers
;;
"create")
echo "Pulling Docker images"
docker-compose --log-level ERROR -f docker-compose/orion.yml pull
docker-compose --log-level ERROR -f docker-compose/scorpio-aaio.yml pull
docker-compose --log-level ERROR -f docker-compose/scorpio-dist.yml pull
;;
*)
echo "Command not Found."
echo "usage: services [create|orion|scorpio|scorpio-dist|stop]"
exit 127;
;;
esac