-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·65 lines (51 loc) · 1.7 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·65 lines (51 loc) · 1.7 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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
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}"
cd "$ROOT_DIR"
if ! command -v uv >/dev/null 2>&1; then
echo "Error: 'uv' is required but not installed." >&2
exit 1
fi
if ! command -v bun >/dev/null 2>&1; then
echo "Error: 'bun' is required but not installed." >&2
exit 1
fi
if [[ ! -d .venv ]]; then
echo "Creating Python environment with uv..."
uv sync
fi
if [[ ! -d frontend/node_modules ]]; then
echo "Installing frontend dependencies with bun..."
(cd frontend && bun install)
fi
cleanup() {
local exit_code=$?
if [[ -n "${BACKEND_PID:-}" ]] && kill -0 "$BACKEND_PID" 2>/dev/null; then
kill "$BACKEND_PID" 2>/dev/null || true
fi
if [[ -n "${FRONTEND_PID:-}" ]] && kill -0 "$FRONTEND_PID" 2>/dev/null; then
kill "$FRONTEND_PID" 2>/dev/null || true
fi
wait "${BACKEND_PID:-}" "${FRONTEND_PID:-}" 2>/dev/null || true
exit "$exit_code"
}
trap cleanup EXIT INT TERM
echo "Starting backend on http://${BACKEND_HOST}:${BACKEND_PORT}"
uv run uvicorn backend.main:app --host "$BACKEND_HOST" --port "$BACKEND_PORT" --reload &
BACKEND_PID=$!
echo "Starting frontend on http://${FRONTEND_HOST}:${FRONTEND_PORT}"
(
cd frontend
bun run vite --host "$FRONTEND_HOST" --port "$FRONTEND_PORT"
) &
FRONTEND_PID=$!
echo
printf 'Prompt Enhancer is starting...\n'
printf 'Backend: http://%s:%s/api/v1/health\n' "$BACKEND_HOST" "$BACKEND_PORT"
printf 'Frontend: http://%s:%s\n' "$FRONTEND_HOST" "$FRONTEND_PORT"
printf 'Press Ctrl+C to stop both services.\n\n'
wait "$BACKEND_PID" "$FRONTEND_PID"