-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·72 lines (55 loc) · 1.39 KB
/
start.sh
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
#!/bin/bash
workdir=$(pwd)
function build_jar() {
echo "Build jar service A"
cd $workdir/serviceA
./gradlew clean build
echo "Build jar service B"
cd $workdir/serviceB
./gradlew clean build
echo "Build jar service C"
cd $workdir/serviceC
./gradlew clean build
echo "Build jar service D"
cd $workdir/serviceD
./gradlew clean build
}
function run_docker() {
docker-compose up -d --build
}
function wait_kibana_health() {
HOST="http://localhost:5601/status"
max_try=24
while [[ "$(curl -s -o /dev/null -L -w ''%{http_code}'' $HOST)" != "200" ]]
do
if [ $max_try -ge 1 ]
then
echo "Waiting for Kibana stay health... $max_try" && sleep 5;
else
echo "Fail start Kibana, check the logs: docker-compose logs"
exit
fi
((max_try--))
done
}
function create_kibana_index() {
echo "Create kibana index for logstash-*"
curl -X POST http://localhost:5601/api/saved_objects/index-pattern/logstash-* -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d '
{
"attributes": {
"title": "logstash-*",
"timeFieldName":"@timestamp"
}
}'
}
function make_requests_example() {
echo "Make some requests to generate logs"
curl http://localhost:8080/servicea/message
sleep 5
curl http://localhost:8080/servicea/message
}
build_jar
run_docker
wait_kibana_health
create_kibana_index
make_requests_example