baic_dashboard/run.sh

41 lines
No EOL
881 B
Bash
Executable file

#!/bin/bash
# Load environment variables from .env file
if [ -f .env ]; then
echo "Loading environment variables from .env file..."
set -a # automatically export all variables
source .env
set +a
else
echo "Warning: .env file not found. Using default values."
fi
# Start the backend server with Hypercorn
echo "Starting backend server with Hypercorn..."
cd backend
python app.py &
BACKEND_PID=$!
# Wait a bit for the backend to start
sleep 2
# Start the frontend dev server
echo "Starting frontend dev server..."
cd ../frontend
npm run dev &
FRONTEND_PID=$!
# Function to handle script termination
cleanup() {
echo "Shutting down servers..."
kill $FRONTEND_PID
kill $BACKEND_PID
exit 0
}
# Set up trap to handle Ctrl+C and other termination signals
trap cleanup INT TERM
# Keep the script running
echo "Both servers are running. Press Ctrl+C to stop."
wait