-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-all.sh
executable file
·86 lines (73 loc) · 1.75 KB
/
run-all.sh
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
#!/bin/bash
# Default values
DURATION=3
FRAMEWORK=""
TEST=""
PIDS=()
# Function to cleanup processes more aggressively
cleanup() {
echo "Cleaning up processes..."
# Kill all running vite processes
pkill -f "vite"
# Kill our tracked processes and their children
for pid in "${PIDS[@]}"; do
# Kill child processes first
pkill -P $pid 2>/dev/null
# Kill the parent process
kill -TERM $pid 2>/dev/null
done
# Final sweep for any remaining vite processes
pkill -9 -f "vite" 2>/dev/null
}
# Set up trap for script termination
trap cleanup EXIT INT TERM
# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
-d | --duration)
DURATION="$2"
shift
;;
--out)
OUT_PATH="$2"
shift
;;
-f | --framework)
FRAMEWORK="$2"
shift
;;
-t | --test)
TEST="$2"
shift
;;
*)
echo "Unknown parameter: $1"
exit 1
;;
esac
shift
done
# Kill any existing vite processes before starting
pkill -f "vite" 2>/dev/null
sleep 1
# Start servers based on framework filter
if [ -z "$FRAMEWORK" ] || [ "$FRAMEWORK" = "react" ]; then
(cd packages/react && npm run preview) &
PIDS+=($!)
REACT_PID=${PIDS[-1]}
fi
if [ -z "$FRAMEWORK" ] || [ "$FRAMEWORK" = "webjsx" ]; then
(cd packages/webjsx && npm run preview -- --port 4174) &
PIDS+=($!)
WEBJSX_PID=${PIDS[-1]}
fi
# Wait for servers to start
sleep 2
# Build the arguments string, properly quoting the test parameter
ARGS=""
[ -n "$FRAMEWORK" ] && ARGS="$ARGS --framework $FRAMEWORK"
[ -n "$TEST" ] && ARGS="$ARGS --test \"$TEST\""
[ -n "$OUT_PATH" ] && ARGS="$ARGS --out \"$OUT_PATH\""
[ -n "$DURATION" ] && ARGS="$ARGS --duration=$DURATION"
# Use eval to properly handle the quoted arguments
eval "node process-benchmarks.js $ARGS"