-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-project.sh
executable file
·55 lines (43 loc) · 1.44 KB
/
run-project.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
#!/bin/bash
function wait_for_service() {
local service_name=$1
local url=$2
local retry_count=20
local retry_interval=10
echo "Waiting for $service_name to be ready at $url..."
for i in $(seq 1 $retry_count); do
if curl -s $url > /dev/null; then
echo "$service_name is up!"
return 0
fi
echo "Waiting for $service_name... (Attempt $i/$retry_count)"
sleep $retry_interval
done
echo "Error: $service_name is not responding at $url"
return 1
}
BASE_DIR=$(pwd)
REBUILD_CONTAINERS=false
# Check for rebuild flag
if [[ "$1" == "--rebuild" ]]; then
REBUILD_CONTAINERS=true
fi
# Start ELK stack
echo "Starting ELK stack..."
docker-compose -f "$BASE_DIR/elk-compose/docker-compose.yml" up -d
# Wait for ELK stack to be up
wait_for_service "Elasticsearch" "http://localhost:9200" || exit 1
wait_for_service "Kibana" "http://localhost:5601" || exit 1
# Start app stack
echo "Starting app stack..."
if [ "$REBUILD_CONTAINERS" = true ]; then
docker-compose -f "$BASE_DIR/docker-compose.yml" up -d --build
else
docker-compose -f "$BASE_DIR/docker-compose.yml" up -d
fi
# Wait for the app to be up (modify according to your app's health check)
wait_for_service "App" "http://localhost:8080/health" || exit 1
# Start Grafana stack
echo "Starting Grafana stack..."
docker-compose -f "$BASE_DIR/monitoring-compose/docker-compose.yml" up -d
echo "All services are up and running!"