Initial commit 4.
This commit is contained in:
@@ -21,6 +21,31 @@ fi
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
REPO_ROOT="$SCRIPT_DIR/.."
|
||||
|
||||
# Cleanup function to kill backend server on script exit
|
||||
cleanup() {
|
||||
echo -e "\n${BLUE}Stopping backend server...${NC}"
|
||||
if [ -n "$BACKEND_PID" ]; then
|
||||
kill $BACKEND_PID 2>/dev/null || true
|
||||
echo -e "${GREEN}Backend server stopped.${NC}"
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Register the cleanup function for script termination
|
||||
trap cleanup INT TERM EXIT
|
||||
|
||||
# Source the .env.dev file to get environment variables
|
||||
if [ -f "$REPO_ROOT/.env.dev" ]; then
|
||||
echo -e "${BLUE}Loading environment variables from .env.dev...${NC}"
|
||||
set -a # automatically export all variables
|
||||
source "$REPO_ROOT/.env.dev"
|
||||
set +a
|
||||
echo -e "${GREEN}Development environment variables loaded.${NC}"
|
||||
else
|
||||
echo -e "${RED}Error:${NC} .env.dev file not found in repository root!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start the backend server
|
||||
cd "$REPO_ROOT/backend" || exit 1
|
||||
echo -e "${BLUE}Starting backend server...${NC}"
|
||||
@@ -42,5 +67,16 @@ else
|
||||
fi
|
||||
|
||||
# Run dev server
|
||||
echo -e "${BLUE}Starting dev server...${NC}"
|
||||
npm run dev
|
||||
echo -e "${BLUE}Starting frontend dev server...${NC}"
|
||||
npm run dev &
|
||||
FRONTEND_PID=$!
|
||||
echo -e "${GREEN}Frontend dev server started with PID $FRONTEND_PID.${NC}"
|
||||
|
||||
# Keep script running until explicitly terminated
|
||||
echo -e "${BLUE}Development environment running. Press Ctrl+C to stop all servers.${NC}"
|
||||
wait $BACKEND_PID
|
||||
echo -e "${YELLOW}Backend server exited. Frontend server may still be running.${NC}"
|
||||
wait $FRONTEND_PID
|
||||
echo -e "${YELLOW}Frontend server exited. Press Ctrl+C to exit the script.${NC}"
|
||||
# Wait indefinitely
|
||||
tail -f /dev/null
|
||||
Reference in New Issue
Block a user