-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstartup.sh
More file actions
45 lines (37 loc) Β· 1.54 KB
/
startup.sh
File metadata and controls
45 lines (37 loc) Β· 1.54 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
#!/bin/sh
# Startup script for Flux Performance Dashboard
# Runs both the Express API server and SvelteKit frontend
set -e
# Exit if either child process dies
trap 'kill $API_PID $FRONTEND_PID 2>/dev/null; exit 1' TERM INT
echo "π Starting Flux Performance Dashboard..."
echo "========================================"
# Start the Express API server in the background
# The API server will read API_PORT (or PORT falls back to 3000 if not set)
echo "π‘ Starting API server on port ${API_PORT:-3000}..."
# Explicitly set PORT for the API server to avoid conflicts
PORT=${API_PORT:-3000} node src/server.js &
API_PID=$!
# Wait for the API server to be ready
echo "β³ Waiting for API server to be ready..."
RETRIES=30
until curl -sf http://127.0.0.1:${API_PORT:-3000}/api/health > /dev/null 2>&1; do
RETRIES=$((RETRIES - 1))
if [ $RETRIES -eq 0 ]; then
echo "β API server failed to start within 30 seconds. Exiting."
exit 1
fi
sleep 1
done
echo "β
API server is ready."
# Start the SvelteKit frontend (using the built app)
echo "π¨ Starting frontend on port ${FRONTEND_PORT:-5173}..."
# Set PORT environment variable for SvelteKit
PORT=${FRONTEND_PORT:-5173} HOST=${HOST:-0.0.0.0} node build/index.js &
FRONTEND_PID=$!
echo "β
Both services started successfully!"
echo " API: http://localhost:${API_PORT:-3000}"
echo " Frontend: http://localhost:${FRONTEND_PORT:-5173}"
echo "========================================"
# Wait for both processes β if either exits, the trap handles cleanup
wait $API_PID $FRONTEND_PID