-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-docker.sh
More file actions
executable file
·100 lines (81 loc) · 2.51 KB
/
run-docker.sh
File metadata and controls
executable file
·100 lines (81 loc) · 2.51 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
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
98
#!/usr/bin/env bash
set -euo pipefail
echo ""
echo "==============================="
echo " Starting OurBusway Platform "
echo "==============================="
echo ""
mkdir -p logs
cleanup() {
echo ""
echo ">> Caught CTRL+C — shutting down Docker Compose..."
# Stop background log streams and Stripe listener if running
if [[ -n "${STRIPE_PID:-}" ]] && ps -p "$STRIPE_PID" >/dev/null 2>&1; then
echo ">> Stopping Stripe webhook listener (PID: $STRIPE_PID)"
kill "$STRIPE_PID" || true
fi
# Kill any background jobs spawned by this script (log followers)
jobs -p | xargs -r kill || true
docker compose down --remove-orphans
echo ">> Shutdown complete."
exit 0
}
trap cleanup INT
echo ">> Ensuring previous environment is cleaned up (safe)"
docker compose down --remove-orphans || true
echo ""
# 4. Clean logs
echo ">> Cleaning old logs..."
rm -f logs/*.log || true
# 6. Start full stack
echo ">> Starting full Docker Compose environment..."
# docker compose $ENV_FILE_ARG up --build -d
docker compose up --build -d
echo ""
SERVICES=(
postgres
rabbit
consul
uaa-service
route-service
ticket-service
payment-service
notification-service
subscription-service
incident-service
gateway-service
frontend
)
echo ">> Streaming logs to logs/<service>.log ..."
for SVC in "${SERVICES[@]}"; do
docker logs -f "$SVC" &> "logs/${SVC}.log" &
done
echo ">> Logs are now being written live into the logs/ folder."
echo ""
# -------------------------------
# 8. Start Stripe webhook listener
# -------------------------------
if command -v stripe >/dev/null 2>&1; then
echo ">> Starting Stripe CLI webhook listener..."
# Forward to Gateway if preferred, otherwise direct to Payment service
# Uncomment next line to forward via Gateway:
# FORWARD_TARGET="localhost:8080/paymentMgtApi/payments/webhook"
# Default: direct to Payment service
FORWARD_TARGET=${FORWARD_TARGET:-"http://localhost:8080/paymentMgtApi/payments/webhook"}
stripe listen --forward-to "$FORWARD_TARGET" &> logs/stripe-webhook.log &
STRIPE_PID=$!
echo ">> Stripe webhook running (PID: $STRIPE_PID) -> $FORWARD_TARGET"
else
echo ">> Stripe CLI not installed — skipping webhook listener."
fi
# -------------------------------
# 9. Background loop to keep script running
# -------------------------------
echo ""
echo "==============================="
echo " OurBusway is now running "
echo " Press CTRL+C to stop "
echo "==============================="
echo ""
# Infinite wait
while true; do sleep 1; done