-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop-server.sh
More file actions
executable file
·68 lines (57 loc) · 2 KB
/
stop-server.sh
File metadata and controls
executable file
·68 lines (57 loc) · 2 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
#!/bin/bash
# Soulfield OS Server Stop Script
set -e
PID_FILE="/tmp/soulfield-server.pid"
LOG_FILE="/tmp/soulfield-server.log"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${BLUE}=====================================${NC}"
echo -e "${BLUE} Stopping Soulfield OS Server${NC}"
echo -e "${BLUE}=====================================${NC}"
echo ""
# Method 1: Kill via PID file
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE")
echo -e "${YELLOW}Found PID file: ${PID}${NC}"
if ps -p $PID > /dev/null 2>&1; then
echo -e "${YELLOW}Killing process ${PID}...${NC}"
kill -9 $PID 2>/dev/null || true
rm -f "$PID_FILE"
echo -e "${GREEN}✓ Server stopped (PID ${PID})${NC}"
else
echo -e "${YELLOW}Process ${PID} not running, cleaning up...${NC}"
rm -f "$PID_FILE"
fi
fi
# Method 2: Kill all node backend/index.cjs processes
echo -e "${YELLOW}Checking for any remaining Soulfield processes...${NC}"
OLD_PIDS=$(pgrep -f "node backend/index.cjs" 2>/dev/null || true)
if [ -n "$OLD_PIDS" ]; then
echo -e "${YELLOW}Found processes: ${OLD_PIDS}${NC}"
echo "$OLD_PIDS" | xargs -r kill -9 2>/dev/null || true
echo -e "${GREEN}✓ All Soulfield processes killed${NC}"
else
echo -e "${GREEN}✓ No running processes found${NC}"
fi
# Method 3: Clear port 8790
echo -e "${YELLOW}Clearing port 8790...${NC}"
PORT_PIDS=$(lsof -ti :8790 2>/dev/null || true)
if [ -n "$PORT_PIDS" ]; then
echo -e "${YELLOW}Found processes on port 8790: ${PORT_PIDS}${NC}"
echo "$PORT_PIDS" | xargs -r kill -9 2>/dev/null || true
echo -e "${GREEN}✓ Port 8790 cleared${NC}"
else
echo -e "${GREEN}✓ Port 8790 already free${NC}"
fi
echo ""
echo -e "${GREEN}✓ Server stopped successfully${NC}"
echo ""
echo -e "Last 20 log lines:"
echo -e "${YELLOW}-----------------------------------${NC}"
tail -20 "$LOG_FILE" 2>/dev/null || echo "(No logs found)"
echo -e "${YELLOW}-----------------------------------${NC}"
echo ""