-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop.sh
More file actions
executable file
·57 lines (49 loc) · 1.65 KB
/
Copy pathstop.sh
File metadata and controls
executable file
·57 lines (49 loc) · 1.65 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
#!/bin/bash
# Colors for output
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}Stopping React Native app and Rails server...${NC}"
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PID_DIR="$SCRIPT_DIR/.pids"
# Stop Rails server
if [ -f "$PID_DIR/rails.pid" ]; then
RAILS_PID=$(cat "$PID_DIR/rails.pid")
if kill -0 "$RAILS_PID" 2>/dev/null; then
echo -e "${RED}Stopping Rails server (PID: $RAILS_PID)...${NC}"
kill "$RAILS_PID"
rm "$PID_DIR/rails.pid"
echo -e "${RED}✓ Rails server stopped${NC}"
else
echo -e "${BLUE}Rails server was not running${NC}"
rm "$PID_DIR/rails.pid"
fi
fi
# Stop Expo/React Native
# Try to find Expo process by name (since it might not have a PID file if running in foreground)
if [ -f "$PID_DIR/expo.pid" ]; then
EXPO_PID=$(cat "$PID_DIR/expo.pid")
if kill -0 "$EXPO_PID" 2>/dev/null; then
echo -e "${RED}Stopping React Native app (PID: $EXPO_PID)...${NC}"
kill "$EXPO_PID"
rm "$PID_DIR/expo.pid"
echo -e "${RED}✓ React Native app stopped${NC}"
else
echo -e "${BLUE}React Native app was not running${NC}"
rm "$PID_DIR/expo.pid"
fi
else
# Try to find and kill Expo processes
EXPO_PIDS=$(pgrep -f "expo start\|expo-router\|metro" | grep -v $$ || true)
if [ -n "$EXPO_PIDS" ]; then
echo -e "${RED}Stopping React Native app...${NC}"
echo "$EXPO_PIDS" | xargs kill 2>/dev/null || true
echo -e "${RED}✓ React Native app stopped${NC}"
fi
fi
# Clean up .pids directory if empty
if [ -d "$PID_DIR" ] && [ -z "$(ls -A "$PID_DIR")" ]; then
rmdir "$PID_DIR"
fi
echo -e "${BLUE}Done!${NC}"