forked from bigwolfeman/Document-MCP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop-dev.sh
More file actions
executable file
·54 lines (44 loc) · 1.6 KB
/
stop-dev.sh
File metadata and controls
executable file
·54 lines (44 loc) · 1.6 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
#!/bin/bash
# Stop development servers for Document Viewer
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKEND_PID_FILE="$PROJECT_ROOT/.backend.pid"
FRONTEND_PID_FILE="$PROJECT_ROOT/.frontend.pid"
echo -e "${RED}Stopping Document Viewer Development Environment${NC}"
echo "=================================================="
_stop_service() {
local pid_file="$1"
local label="$2"
local port="$3"
if [ -f "$pid_file" ]; then
local pid
pid=$(cat "$pid_file")
if ps -p "$pid" > /dev/null 2>&1; then
echo "Stopping $label (PID: $pid and children)..."
# Kill the process group to catch uvicorn reload child workers
kill -- "-$pid" 2>/dev/null || kill "$pid" 2>/dev/null
sleep 1
ps -p "$pid" > /dev/null 2>&1 && kill -9 "$pid" 2>/dev/null
fi
rm -f "$pid_file"
fi
# Also kill anything still holding the port (catches orphaned children)
if [ -n "$port" ]; then
local port_pid
port_pid=$(lsof -ti tcp:"$port" 2>/dev/null)
if [ -n "$port_pid" ]; then
echo "Killing process on port $port (PID: $port_pid)..."
kill "$port_pid" 2>/dev/null
sleep 0.5
kill -0 "$port_pid" 2>/dev/null && kill -9 "$port_pid" 2>/dev/null
fi
fi
echo -e "${GREEN}✓ $label stopped${NC}"
}
_stop_service "$BACKEND_PID_FILE" "Backend" 8000
_stop_service "$FRONTEND_PID_FILE" "Frontend" 5173
echo ""
echo -e "${GREEN}Development servers stopped${NC}"