-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathstop.sh
More file actions
executable file
·75 lines (64 loc) · 2.08 KB
/
stop.sh
File metadata and controls
executable file
·75 lines (64 loc) · 2.08 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
#!/usr/bin/env bash
set -euo pipefail
# =============================================================================
# stop.sh — Stop all local development services and Docker infrastructure
#
# Reads .local-dev.pids, sends SIGTERM, waits for graceful shutdown,
# then SIGKILL any remaining processes. Removes PID file when done.
# Also tears down Docker infrastructure (Milvus, Phoenix, MinIO).
# =============================================================================
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
PID_FILE="$ROOT_DIR/.local-dev.pids"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
info() { printf "${CYAN}[INFO]${NC} %s\n" "$1"; }
ok() { printf "${GREEN}[OK]${NC} %s\n" "$1"; }
warn() { printf "${YELLOW}[WARN]${NC} %s\n" "$1"; }
if [ ! -f "$PID_FILE" ]; then
warn "No .local-dev.pids file found. Nothing to stop."
exit 0
fi
info "Stopping services..."
# Send SIGTERM to all
while IFS=: read -r pid name; do
if kill -0 "$pid" 2>/dev/null; then
kill "$pid" 2>/dev/null || true
info " Sent SIGTERM to $name (PID $pid)"
else
warn " $name (PID $pid) already stopped"
fi
done < "$PID_FILE"
# Wait up to 5 seconds for graceful shutdown
info "Waiting up to 5s for graceful shutdown..."
for i in 1 2 3 4 5; do
ALL_DEAD=true
while IFS=: read -r pid name; do
if kill -0 "$pid" 2>/dev/null; then
ALL_DEAD=false
break
fi
done < "$PID_FILE"
if $ALL_DEAD; then
break
fi
sleep 1
done
# SIGKILL any remaining
while IFS=: read -r pid name; do
if kill -0 "$pid" 2>/dev/null; then
kill -9 "$pid" 2>/dev/null || true
warn " Sent SIGKILL to $name (PID $pid)"
fi
done < "$PID_FILE"
rm -f "$PID_FILE"
ok "All local services stopped. PID file removed."
# Stop Docker infrastructure
info "Stopping Docker infrastructure..."
if docker compose -f "$ROOT_DIR/docker-compose.infra.yml" down 2>/dev/null; then
ok "Docker infrastructure stopped"
else
warn "Docker infrastructure was not running or docker compose failed"
fi