-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-source-mac.sh
More file actions
executable file
·104 lines (89 loc) · 2.88 KB
/
run-source-mac.sh
File metadata and controls
executable file
·104 lines (89 loc) · 2.88 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
#!/bin/bash
#
# StreamGRID - macOS Source Runner
# Clean start script with port management
#
set -e
DEV_SERVER_PORT=52774
ELECTRON_DEBUG_PORT=60000
ELECTRON_INSPECT_PORT=63689
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
NC='\033[0m'
print_header() {
echo -e "${CYAN}"
echo "================================================================"
echo " StreamGRID - macOS Source Runner"
echo "================================================================"
echo -e "${NC}"
}
check_and_kill_port() {
local port=$1
local name=$2
local pid=$(lsof -ti :$port 2>/dev/null || true)
if [ -n "$pid" ]; then
echo -e "${YELLOW}[CLEANUP]${NC} Killing process on port $port ($name) - PID: $pid"
kill -9 $pid 2>/dev/null || true
sleep 0.5
fi
}
kill_zombie_electrons() {
echo -e "${BLUE}[CLEANUP]${NC} Checking for orphaned Electron processes..."
local pids=$(pgrep -f "electron.*$(basename $(pwd))" 2>/dev/null || true)
if [ -n "$pids" ]; then
echo -e "${YELLOW}[CLEANUP]${NC} Killing orphaned Electron processes: $pids"
echo "$pids" | xargs kill -9 2>/dev/null || true
sleep 1
fi
}
check_dependencies() {
echo -e "${BLUE}[CHECK]${NC} Verifying dependencies..."
if ! command -v node &> /dev/null; then
echo -e "${RED}[ERROR]${NC} Node.js is not installed!"
echo " Install from: https://nodejs.org or use 'brew install node'"
exit 1
fi
echo -e "${GREEN}[OK]${NC} Node.js $(node --version)"
if ! command -v npm &> /dev/null; then
echo -e "${RED}[ERROR]${NC} npm is not installed!"
exit 1
fi
echo -e "${GREEN}[OK]${NC} npm $(npm --version)"
if [ ! -d "node_modules" ]; then
echo -e "${YELLOW}[SETUP]${NC} Installing dependencies..."
npm install
fi
}
cd "$(dirname "$0")"
print_header
echo -e "${BLUE}[INFO]${NC} Working directory: $(pwd)"
echo ""
echo -e "${CYAN}--- CLEANUP PHASE ---${NC}"
kill_zombie_electrons
check_and_kill_port $DEV_SERVER_PORT "Dev Server"
check_and_kill_port $ELECTRON_DEBUG_PORT "Electron Debug"
check_and_kill_port $ELECTRON_INSPECT_PORT "Electron Inspect"
echo ""
echo -e "${CYAN}--- VERIFICATION PHASE ---${NC}"
check_dependencies
echo ""
echo -e "${CYAN}--- BUILD PHASE ---${NC}"
echo -e "${BLUE}[BUILD]${NC} Compiling main process TypeScript..."
npm run build:main
echo -e "${GREEN}[OK]${NC} Main process compiled"
echo ""
echo -e "${CYAN}--- LAUNCH PHASE ---${NC}"
echo -e "${GREEN}[START]${NC} Launching StreamGRID..."
echo ""
export NODE_ENV=development
if [ "$1" = "--dev" ] || [ "$1" = "-d" ]; then
echo -e "${MAGENTA}[MODE]${NC} Development mode with DevTools"
npx electron . --dev --remote-debugging-port=$ELECTRON_DEBUG_PORT --inspect=$ELECTRON_INSPECT_PORT
else
echo -e "${GREEN}[MODE]${NC} Standard mode"
npx electron .
fi