-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_dev.sh
More file actions
executable file
·69 lines (57 loc) · 2.08 KB
/
start_dev.sh
File metadata and controls
executable file
·69 lines (57 loc) · 2.08 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
#!/usr/bin/env bash
# start_dev.sh
# MapToPoster Dev Server Launcher (runs frontend & backend concurrently)
# Color helpers
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${BLUE}==================================================${NC}"
echo -e "${GREEN} Starting MapToPoster Developer Services ${NC}"
echo -e "${BLUE}==================================================${NC}"
# Find repository root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Check if environment is setup
if [ ! -d .venv ]; then
echo -e "${RED}Error: Virtual environment (.venv) not found. Run ./setup_dev.sh first.${NC}"
exit 1
fi
if [ ! -d web/frontend/node_modules ]; then
echo -e "${RED}Error: Node modules not found. Run ./setup_dev.sh first.${NC}"
exit 1
fi
# Function to clean up background tasks on exit
cleanup() {
echo -e "\n${YELLOW}Stopping development servers...${NC}"
if [ ! -z "$BACKEND_PID" ]; then
kill "$BACKEND_PID" 2>/dev/null || true
fi
if [ ! -z "$FRONTEND_PID" ]; then
kill "$FRONTEND_PID" 2>/dev/null || true
fi
echo -e "${GREEN}Services stopped successfully.${NC}"
exit 0
}
# Trap INT and TERM signals to trigger cleanup
trap cleanup INT TERM EXIT
# 1. Start backend FastAPI
echo -e "${BLUE}Starting FastAPI Backend on http://localhost:8000...${NC}"
cd "$SCRIPT_DIR/web/backend"
# Use absolute path to the venv interpreter
../.venv/bin/uvicorn main:app --host 127.0.0.1 --port 8000 --reload &
BACKEND_PID=$!
# Wait a brief moment to ensure backend is starting
sleep 1.5
# 2. Start frontend Next.js
echo -e "${BLUE}Starting Next.js Frontend on http://localhost:3000...${NC}"
cd "$SCRIPT_DIR/web/frontend"
npm run dev &
FRONTEND_PID=$!
echo -e "${GREEN}✓ Both services started successfully!${NC}"
echo -e "- Backend docs: ${YELLOW}http://localhost:8000/api/swagger${NC}"
echo -e "- Frontend App: ${YELLOW}http://localhost:3000${NC}"
echo -e "Press ${YELLOW}Ctrl+C${NC} to exit and stop all services."
# Keep script running and wait for background processes
wait