Split project into frontend and backend
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
BACKEND_DIR="$ROOT_DIR/backend"
|
||||
FRONTEND_DIR="$ROOT_DIR/frontend"
|
||||
|
||||
BACKEND_HOST="${BACKEND_HOST:-127.0.0.1}"
|
||||
BACKEND_PORT="${BACKEND_PORT:-8000}"
|
||||
FRONTEND_HOST="${FRONTEND_HOST:-127.0.0.1}"
|
||||
FRONTEND_PORT="${FRONTEND_PORT:-5173}"
|
||||
RUN_NAME="${RUN_NAME:-frontend_split_motor_7nm}"
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "${BACKEND_PID:-}" ]]; then
|
||||
kill "$BACKEND_PID" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
if [[ ! -d "$FRONTEND_DIR/node_modules" ]]; then
|
||||
echo "Installing frontend dependencies..."
|
||||
(cd "$FRONTEND_DIR" && npm install)
|
||||
fi
|
||||
|
||||
echo "Starting backend on http://$BACKEND_HOST:$BACKEND_PORT"
|
||||
(
|
||||
cd "$BACKEND_DIR"
|
||||
python -m src.dev_server --host "$BACKEND_HOST" --port "$BACKEND_PORT" --run-name "$RUN_NAME"
|
||||
) &
|
||||
BACKEND_PID=$!
|
||||
|
||||
echo "Starting frontend on http://$FRONTEND_HOST:$FRONTEND_PORT"
|
||||
cd "$FRONTEND_DIR"
|
||||
npm run dev -- --host "$FRONTEND_HOST" --port "$FRONTEND_PORT"
|
||||
Reference in New Issue
Block a user