-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequential-up.sh
More file actions
54 lines (45 loc) Β· 1.56 KB
/
sequential-up.sh
File metadata and controls
54 lines (45 loc) Β· 1.56 KB
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
#!/bin/bash
# Services Configuration
INFRA_SERVICES="zookeeper kafka kafka-init postgres postgres-auth mongodb redis prometheus grafana jaeger"
APP_SERVICES="authentication-service product-service order-service notification-service"
show_help() {
echo "Usage: ./sequential-up.sh [up] [--build]"
echo ""
echo "Description:"
echo " Starts the environment sequentially in detached mode (-d) to save RAM/CPU."
echo ""
echo "Examples:"
echo " ./sequential-up.sh --build # Rebuild and start everything"
echo " ./sequential-up.sh up # Start existing containers"
echo ""
}
# Show help if no arguments
if [ $# -eq 0 ] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
show_help
exit 0
fi
# Clean up arguments: remove 'up' or '-d' if the user typed them
# since we will enforce 'up -d' anyway.
CLEAN_ARGS=""
for arg in "$@"; do
if [[ "$arg" != "up" && "$arg" != "-d" ]]; then
CLEAN_ARGS="$CLEAN_ARGS $arg"
fi
done
echo "π [1/2] Starting Infrastructure..."
docker-compose up -d $INFRA_SERVICES
echo "β³ Waiting 15s for stability..."
sleep 15
echo "π [2/2] Starting Apps Sequentially..."
for service in $APP_SERVICES; do
echo "π Processing [$service]..."
# Always enforce 'up -d' and append remaining user flags (like --build)
docker-compose up -d $CLEAN_ARGS $service
if [ $? -ne 0 ]; then
echo "β Error: Failed to start $service. Aborting."
exit 1
fi
echo "β
$service is up."
echo "----------------------------------------"
done
echo "β¨ Environment is ready!"