forked from dullage/flatnotes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·79 lines (66 loc) · 1.96 KB
/
dev.sh
File metadata and controls
executable file
·79 lines (66 loc) · 1.96 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Development script for flatnotes
# Starts both backend (uvicorn with reload) and frontend (vite dev server)
set -e
cleanup() {
echo ""
echo "Shutting down..."
if [ -n "$BACKEND_PID" ]; then
kill $BACKEND_PID 2>/dev/null || true
fi
if [ -n "$FRONTEND_PID" ]; then
kill $FRONTEND_PID 2>/dev/null || true
fi
exit 0
}
trap cleanup SIGINT SIGTERM
echo "Starting flatnotes development servers..."
echo ""
# Set default environment variables if not set
export FLATNOTES_PATH="${FLATNOTES_PATH:-./data}"
export FLATNOTES_AUTH_TYPE="${FLATNOTES_AUTH_TYPE:-password}"
export FLATNOTES_USERNAME="${FLATNOTES_USERNAME:-user}"
export FLATNOTES_PASSWORD="${FLATNOTES_PASSWORD:-changeMe!}"
export FLATNOTES_SECRET_KEY="${FLATNOTES_SECRET_KEY:-developmentSecretKey123}"
# Create data directory if it doesn't exist
mkdir -p "$FLATNOTES_PATH"
# Build frontend if dist doesn't exist (required for backend)
if [ ! -f "client/dist/index.html" ]; then
echo "Building frontend (first time setup)..."
npm run build
echo ""
fi
# Start backend (uvicorn with hot reload on port 8000)
echo "Starting backend on http://127.0.0.1:8000"
python -m uvicorn main:app \
--app-dir server \
--host 127.0.0.1 \
--port 8000 \
--reload \
--reload-dir server &
BACKEND_PID=$!
# Wait for backend to be ready
echo "Waiting for backend to start..."
for i in {1..30}; do
if curl -s http://127.0.0.1:8000/health > /dev/null 2>&1; then
echo "Backend is ready!"
break
fi
sleep 1
done
# Start frontend (vite dev server on port 8080)
echo "Starting frontend on http://127.0.0.1:8080"
npm run dev &
FRONTEND_PID=$!
echo ""
echo "Development servers started!"
echo " Frontend: http://127.0.0.1:8080"
echo " Backend: http://127.0.0.1:8000"
echo " API Docs: http://127.0.0.1:8000/docs"
echo ""
echo "Default login: user / changeMe!"
echo ""
echo "Press Ctrl+C to stop both servers"
echo ""
# Wait for both processes
wait