gohorsejobs/run_dev.sh
Tiago Yamamoto 18ac6d74f0 chore: update port configuration to avoid conflicts
Port Configuration:
- Backend: 8521 (was 8080/8158)
- Frontend: 8963 (was 3000)

Files updated:
- backend/.env.example: updated PORT and CORS_ORIGINS
- frontend/src/lib/auth.ts: API_URL default to 8521
- frontend/src/lib/api.ts: API_URL default to 8521
- frontend/src/lib/storage.ts: API_URL default to 8521
- run_dev.sh: added port flags and service info display

Usage:
  ./run_dev.sh
  # Backend:  http://localhost:8521
  # Frontend: http://localhost:8963
2025-12-11 17:06:37 -03:00

60 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
# Function to kill background processes on exit
cleanup() {
echo "Stopping services..."
kill $(jobs -p) 2>/dev/null
exit
}
trap cleanup SIGINT SIGTERM
echo "🚀 Starting GoHorseJobs Development Environment..."
# Update Backend
echo "🔹 Checking Backend Dependencies..."
cd backend && go mod tidy
# Generate Swagger Docs
# Generate Swagger Docs
if ! command -v swag &> /dev/null; then
if [ -f "$HOME/go/bin/swag" ]; then
export PATH=$PATH:$HOME/go/bin
else
echo "⚠️ 'swag' command not found. Installing..."
go install github.com/swaggo/swag/cmd/swag@latest
export PATH=$PATH:$HOME/go/bin
fi
fi
echo "🔹 Generating Swagger Docs..."
swag init -g cmd/api/main.go --parseDependency --parseInternal
cd ..
# Check Frontend Dependencies
echo "🔹 Checking Frontend Dependencies..."
if [ ! -d "frontend/node_modules" ]; then
echo "⚠️ node_modules not found. Running npm install..."
cd frontend && npm install && cd ..
fi
# Start Backend
echo "🔹 Starting Backend (Go) on port 8521..."
(cd backend && go run cmd/api/main.go) &
BACKEND_PID=$!
# Wait a moment for backend to initialize
sleep 2
# Start Frontend
echo "🔹 Starting Frontend (Next.js) on port 8963..."
(cd frontend && npm run dev -- -p 8963) &
FRONTEND_PID=$!
echo ""
echo "📡 Services running:"
echo " - Backend: http://localhost:8521"
echo " - Frontend: http://localhost:8963"
echo ""
# Wait for both processes
wait $BACKEND_PID $FRONTEND_PID