-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathralph-stop.sh
More file actions
executable file
·78 lines (66 loc) · 2.21 KB
/
ralph-stop.sh
File metadata and controls
executable file
·78 lines (66 loc) · 2.21 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
#!/bin/bash
#
# ralph-stop.sh - Stop Ralph and clean up worktree
#
# Usage: ./ralph-stop.sh [worktree-name]
#
set -e
WORKTREE_NAME="${1:-ralph-testing}"
WORKTREE_PATH="../${WORKTREE_NAME}"
BRANCH_NAME="ralph/${WORKTREE_NAME}"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}🛑 Ralph Stop & Cleanup${NC}"
echo "========================"
# Kill any running Ralph/Copilot processes
echo -e "${YELLOW}Stopping Ralph processes...${NC}"
pkill -f "copilot.*ralph" 2>/dev/null || true
pkill -f "gh copilot" 2>/dev/null || true
# Stop wp-env in worktree if it exists
if [ -d "$WORKTREE_PATH" ]; then
echo -e "${YELLOW}Stopping wp-env in worktree...${NC}"
cd "$WORKTREE_PATH"
npm run env:stop 2>/dev/null || true
cd - > /dev/null
fi
# Stop wp-env in main project
if [ -f ".wp-env.json" ]; then
echo -e "${YELLOW}Stopping wp-env in main project...${NC}"
npm run env:stop 2>/dev/null || true
fi
# Clean up orphaned Docker containers holding ports
echo -e "${YELLOW}Cleaning up Docker containers...${NC}"
docker stop $(docker ps -q --filter "name=wordpress" --filter "name=mysql") 2>/dev/null || true
docker rm $(docker ps -aq --filter "name=wordpress" --filter "name=mysql") 2>/dev/null || true
echo ""
echo -e "${GREEN}✅ Ralph stopped${NC}"
# Ask about cleanup
echo ""
read -p "Remove worktree '$WORKTREE_PATH'? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}Removing worktree...${NC}"
git worktree remove "$WORKTREE_PATH" --force 2>/dev/null || true
git branch -D "$BRANCH_NAME" 2>/dev/null || true
echo -e "${GREEN}✅ Worktree removed${NC}"
else
echo -e "Worktree kept at: ${WORKTREE_PATH}"
echo -e "Branch: ${BRANCH_NAME}"
echo ""
echo "To merge changes back to main:"
echo " git checkout main"
echo " git merge ${BRANCH_NAME}"
echo ""
echo "To remove later:"
echo " git worktree remove ${WORKTREE_PATH}"
echo " git branch -D ${BRANCH_NAME}"
fi
# Clean up temp files
echo -e "${YELLOW}Cleaning up temp files...${NC}"
rm -f .ralph-context.*.* 2>/dev/null || true
rm -f "$WORKTREE_PATH"/.ralph-context.*.* 2>/dev/null || true
echo ""
echo -e "${GREEN}✅ Cleanup complete${NC}"