-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·103 lines (85 loc) · 2.76 KB
/
dev.sh
File metadata and controls
executable file
·103 lines (85 loc) · 2.76 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
#!/bin/bash
# Development startup script for KubeStellar Console
set -e
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SCRIPT_DIR="$PROJECT_DIR"
# Load shared port cleanup utilities (kill_project_port, verify_port_free)
source "$PROJECT_DIR/scripts/port-cleanup.sh"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}=== KubeStellar Console Development Server ===${NC}"
# Check required environment variables
if [ -z "$GITHUB_CLIENT_ID" ]; then
echo -e "${RED}Error: GITHUB_CLIENT_ID is not set${NC}"
echo ""
echo "To create a GitHub OAuth App:"
echo "1. Go to https://github.com/settings/developers"
echo "2. Click 'New OAuth App'"
echo "3. Set the following:"
echo " - Application name: KubeStellar Console (Dev)"
echo " - Homepage URL: http://localhost:5174"
echo " - Authorization callback URL: http://localhost:8080/auth/github/callback"
echo "4. Copy the Client ID and generate a Client Secret"
echo ""
echo "Then set the environment variables:"
echo " export GITHUB_CLIENT_ID=<your-client-id>"
echo " export GITHUB_CLIENT_SECRET=<your-client-secret>"
exit 1
fi
if [ -z "$GITHUB_CLIENT_SECRET" ]; then
echo -e "${RED}Error: GITHUB_CLIENT_SECRET is not set${NC}"
exit 1
fi
# Set development defaults
export DEV_MODE=true
export PORT=${PORT:-8080}
export FRONTEND_URL=${FRONTEND_URL:-http://localhost:5174}
# Create data directory if it doesn't exist
mkdir -p ./data
echo -e "${GREEN}Configuration:${NC}"
echo " Backend Port: $PORT"
echo " Frontend URL: $FRONTEND_URL"
echo " Database: ./data/console.db"
echo " MCP Ops: ${KUBESTELLAR_OPS_PATH:-kubestellar-ops}"
echo " MCP Deploy: ${KUBESTELLAR_DEPLOY_PATH:-kubestellar-deploy}"
echo ""
# Clear project processes on required ports; unrelated services are left running
kill_project_port "$PORT"
kill_project_port 5174
# Verify all required ports are free before proceeding
for p in $PORT 5174; do
if ! verify_port_free "$p"; then
exit 1
fi
done
# Function to cleanup on exit
cleanup() {
echo -e "\n${YELLOW}Shutting down...${NC}"
kill $BACKEND_PID 2>/dev/null || true
kill $FRONTEND_PID 2>/dev/null || true
exit 0
}
trap cleanup SIGINT SIGTERM
# Start backend
echo -e "${GREEN}Starting backend...${NC}"
GOWORK=off go run ./cmd/console --dev &
BACKEND_PID=$!
# Wait a bit for backend to start
sleep 2
# Start frontend
echo -e "${GREEN}Starting frontend...${NC}"
(cd web && npm run dev) &
FRONTEND_PID=$!
echo ""
echo -e "${GREEN}=== Console is running ===${NC}"
echo ""
echo " Frontend: http://localhost:5174"
echo " Backend: http://localhost:$PORT"
echo " API: http://localhost:$PORT/api"
echo ""
echo "Press Ctrl+C to stop"
# Wait for either process to exit
wait