-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathorchestrator-startup.sh
More file actions
executable file
·116 lines (94 loc) · 3.45 KB
/
orchestrator-startup.sh
File metadata and controls
executable file
·116 lines (94 loc) · 3.45 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# Claude Orchestrator One-Click Startup Script
set -e
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
ORCHESTRATOR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
export ORCHESTRATOR_PORT="${ORCHESTRATOR_PORT:-4000}"
CLIENT_PORT=2080
echo -e "${BLUE}🚀 Claude Orchestrator Startup${NC}"
echo -e "${BLUE}================================${NC}"
# Check if already running
if lsof -i:$CLIENT_PORT >/dev/null 2>&1; then
echo -e "${GREEN}✅ Orchestrator already running${NC}"
echo -e "${BLUE}Opening browser...${NC}"
# Just open browser
if command -v xdg-open >/dev/null; then
xdg-open "http://localhost:$CLIENT_PORT" >/dev/null 2>&1 &
elif command -v open >/dev/null; then
open "http://localhost:$CLIENT_PORT"
fi
echo -e "${GREEN}🎉 Claude Orchestrator ready at http://localhost:$CLIENT_PORT${NC}"
exit 0
fi
# Navigate to orchestrator
cd "$ORCHESTRATOR_DIR" || {
echo -e "${RED}❌ Orchestrator directory not found: $ORCHESTRATOR_DIR${NC}"
exit 1
}
# Optional: Update to latest (can be disabled with --no-update flag)
if [[ "$1" != "--no-update" ]]; then
echo -e "${BLUE}📥 Checking for updates...${NC}"
git fetch origin main >/dev/null 2>&1 || true
LOCAL=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
REMOTE=$(git rev-parse origin/main 2>/dev/null || echo "unknown")
if [ "$LOCAL" != "$REMOTE" ] && [ "$REMOTE" != "unknown" ]; then
echo -e "${BLUE}⬇️ Pulling updates...${NC}"
git pull --ff-only origin main 2>/dev/null || echo -e "${YELLOW}⚠ Could not pull (offline?)${NC}"
# Update dependencies if package.json changed
if git diff --name-only HEAD~1..HEAD 2>/dev/null | grep -q package.json; then
echo -e "${BLUE}📦 Updating dependencies...${NC}"
npm install >/dev/null 2>&1 || echo -e "${YELLOW}⚠ Could not update deps${NC}"
fi
else
echo -e "${GREEN}✅ Already up to date${NC}"
fi
fi
# Ensure workspace system is set up
echo -e "${BLUE}🔧 Setting up workspace system...${NC}"
if [ ! -d ~/.orchestrator ]; then
echo -e "${BLUE}📁 Creating workspace directories...${NC}"
node scripts/migrate-to-workspaces.js >/dev/null 2>&1 || {
echo -e "${RED}❌ Failed to set up workspace system${NC}"
exit 1
}
echo -e "${GREEN}✅ Workspace system initialized${NC}"
fi
# Start services in background
echo -e "${BLUE}🔧 Starting orchestrator services...${NC}"
npm run dev:all >/dev/null 2>&1 &
ORCH_PID=$!
# Wait for services to be ready (check client port)
echo -e "${BLUE}⏳ Waiting for services to be ready...${NC}"
TIMEOUT=30
ELAPSED=0
while ! lsof -i:$CLIENT_PORT >/dev/null 2>&1; do
sleep 0.5
ELAPSED=$((ELAPSED + 1))
if [ $ELAPSED -gt $((TIMEOUT * 2)) ]; then
echo -e "${RED}❌ Timeout waiting for services${NC}"
kill $ORCH_PID 2>/dev/null
exit 1
fi
# Show progress dots
if [ $((ELAPSED % 4)) -eq 0 ]; then
echo -n "."
fi
done
echo -e "\n${GREEN}✅ Services ready!${NC}"
# Open browser automatically
echo -e "${BLUE}🌐 Opening orchestrator...${NC}"
sleep 1
if command -v xdg-open >/dev/null; then
xdg-open "http://localhost:$CLIENT_PORT" >/dev/null 2>&1 &
elif command -v open >/dev/null; then
open "http://localhost:$CLIENT_PORT"
fi
echo -e "${GREEN}🎉 Claude Orchestrator ready at http://localhost:$CLIENT_PORT${NC}"
echo -e "${BLUE}💡 Press Ctrl+C to stop services${NC}"
echo -e "${BLUE}💡 Run with --no-update to skip git pull${NC}"
# Keep script running to show it's active
wait $ORCH_PID